-
Notifications
You must be signed in to change notification settings - Fork 2
Usage
bugzbrown edited this page Mar 26, 2013
·
2 revisions
#Usage
##Load the library: You can load the library on a method by method basis or you can add it to the constructor for a controller or even add it to the autoload file.
$this->load->library('facebook/fb');##Initialize the Facebook Object In any of your controllers you can initialize the facebook object like this:
$this->fb->init_facebook();This will automatically check to see if the user is logged and authenticated with your app, if he is not, it will do the authentication thingy with facebook, and redirect the user back to the canvas page.
Once the user is authenticated, it will create a couple of necessary objects that can be used:
echo $this->fb->user;##The Graph API Method:
$profile = $this->fb->api('/me','GET')
echo $profile['name'];##The FQL method:
$retval = $this->fb->fql('SELECT name FROM user WHERE uid = '. $this->fb->user);
echo $retval[0]['name'];echo '<a href="' . $this->fb->logout_url . '">Logout</a>';