Skip to content

AhsanShabbir/facebook-sdk-v5-with-Codeigniter-3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

facebook-sdk-v5-with-Codeigniter-3

@author: Ahsan Shabbir

@email: [email protected]

#Installation

cd application/

composer install.

Composer will download facebook sdk in application/vendor directory.

#update config/facebook.php file.

go to application/config/facebook.php file and update it with your facebook app credentials.

#Change Config file

in config.php set composer autoload config as TRUE

$config['composer_autoload'] = TRUE;

Config/autoload.php

in config/autoload.php add facebook in autload library array.

$autoload['libraries'] = array('facebook');

#Library Details

This library use latest facebook api to communicate. I have written following helper methods

 - loginUrl()
     this helper method will return login url for user to login with facebook. 
     Usage: $this->facebook->loginUrl();  
      
 - logged_in()
      This Helper method will check if user is logged in or not. Return TRUE or False.
      Usage: $this->facebook->logged_in();
      
 - setSession()
      This helper method is used in login callback. This function is responsible for generating user sessions.
      When user visit url generated by loginUrl(), he must be directed to this function. 
      (controller loads it.. check controllers/Fb.php file for more).
      
 - getProfile()
      This helper method return currently logged in user. And return array of user's data.
      Usage: $this->facebook->getProfile();
      
 - getDb()
      A helper method to return facbeook current profile picture url. 
      Usage: $imgSource = $this->facebook->getDp();
      
 - getUserId()

    Sometimes we only need to get userID for checking/comparing user or stuff like that.. this helper method will save your time
    and return user id only.
      
 - getFriends()
      As name of method, this method get list of friends of the user who are already using this app. 
      If no friend of user use this app, this method will only return number of his friends. 
      
 - getPosts()
      This helper method require permission 'user_posts'. 
      Usage: $data = $this->facebook->getPosts();
      It will return an array of user posts/timeline.

 - updateStatus($message)
      This helper method will update facebook status of user. But it require 'Publish_actions' permission. 
      usage: 
        $msg = "Hello, Im posting this status with my new app";
        $this->facebook->updateStatus($message)
        
 - uploadImage($message, $imagePath)
        A helper method to upload images on user facebook timeline. It also require 'publish actions' permission.
        Usage: 
        $msg= "my new selfie";
        $img = "/home/ahsan/pictures/selfie.jpg';
        $this->facebook->uploadImage($msg,$img);
 
  - uploadVideo($title, $description, $video_source)
        By calling this function, given video will be uploaded to user timeline. 
        Usage:
          $title = "New Video";
          $desc = "This video is not a simple uploaded video. I used facebook api helper by Ahsan Shabbir here";
          $video = "/home/ahsan/videos/my-new-video.mp4";
          $this->facebook->uploadVideo($title, $desc, $video);
          
 - logoutUrl()
        This helper method will return url where user is to be redirected after he logged out of facebook. 
        Value can be set in config/facebook.php file. 
        
 - logout()
          
        delete user data and destroy session and redirect to logoutUrl() automatically. 

#If you find any issues in the code. Please give me your feedback. Any advice and suggestions will be greatly appreciated ...

About

Facebook SDK v5 integeration with Codeigniter 3

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published