• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Facebook PHP SDK v3.0.0 with CodeIgniter v2.0.2 - How to integrate?

Facebook have released v3.0.0 of their PHP SDK... Does anyone have some tips on how to integrate this into CodeIgniter v2.0.2?

I'm rather new to CI - so step-by-step tips would be great (for me and others I'm sure).

Would prefer to keep it simple - and not use some special third-party library - just keep to the core Facebook library.

Quote:The new PHP SDK (v3.0.0) is a major upgrade to the older one (v2.2.x):

1. Uses OAuth authentication flows instead of legacy authentication flow
2. Consists of two classes. The first (class BaseFacebook) maintains the core of the upgrade, and the second one (class Facebook) is a small subclass that uses PHP sessions to store the user id and access token.

Facebook Dev Blog: Upgrade to PHP SDK v3.0.0

GitHub Source

FYI I'm going to start by looking over these for some tips:

Thanks in advance for any help you have to offer ^_^

[eluser]Calebe Aires[/eluser]
Try this, the best I have found!


Thanks Calebe,

It looks like that project has some interesting code for handling request id's.... which co-indecently is something I'm working on today (great timing!).

I seems the demo url isn't totally working as expected

1st it redirected to the developers url (after FB permissions) and not back to the Facebook app canvas url.

Also the "Try a request" and "Try publishing to your feed" links did not work for me...

Could be because I am on Firebox 5 (beta) ... or that PHP SDK v3.0.0 is not compatible yet with JavaScript SDK logins.... have 4 weeks to wait!: http://developers.facebook.com/blog/post/503

For this reason I have stuck with v2.1.2 of the PHP SDK (for now).

For integration I have done the following:

1. Renamed the SDK file "facebook.php" to "Facebook.php"
2. Added this to the top line of that file:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
3. put that modified SDK file in /application/libraries/
4. Added my own "facebook.php" config file to /application/config/ (includes: app id, api key, secret key, canvas url, and several other useful urls )
5. In /application/config/autoload.php I auto load the "facebook" config file
$autoload['config'] = array('facebook');
6. In my controller after loading the "facebook" SDK library I can access it via $this->facebook:
$fb_config = array(
  'appId'  => $this->config->item('fb_app_id'),
  'secret' => $this->config->item('fb_secret_key'),
  'cookie' => $this->config->item('fb_cookie_enabled'), // enable optional cookie support
  'domain' => $this->config->item('fb_cookie_basedomain'),
  'fileUpload' => $this->config->item('fb_fileupload_enabled')
$this->load->library('facebook', $fb_config);
$data['facebook'] =& $this->facebook;

$this->load->view('welcome', $data);
7. And in my template I can access the Facebook object via $facebook

FYI I'm not sure about assigning by reference on the line:
$data['facebook'] =& $this->facebook;
... if anyone wants to let me know if this is a good or bad idea that would be appreciated.

P.S I have have a Controller named "site"; with the Views: index, canvas, tab, privacy, terms. And "no-view" controllers for: deauthorize ... and working on an "invite" controller for multi-friend-selector id capturing. For my app all the action takes place in the /site/tab/ controller since my app is to be used as a tab on Facebook Pages. I'm using the JavaScript SDK to parse XFBML and subscribe to "like"/"un-like" events for the page.

[eluser]Calebe Aires[/eluser]
Have you donne some with SDK 3.0?

hi chrisjacob
i interest with your tutorial, step by step, but would you like to exlain it more detail like when you create your own config file what it's look like, and more detail step.
and what about the base_facebook.php that already came from facebook-php-sdk?where did you put it on?
thank you

[eluser]Nisha S.[/eluser]
May be you can refer my blog entry on http://www.betterhelpworld.com/codeignit...odeigniter.

[quote author="Nisha S." date="1308159424"]May be you can refer my blog entry on http://www.betterhelpworld.com/codeignit...odeigniter.[/quote]

It will be useful to others users API REST https://github.com/philsturgeon/codeigniter-restserver add doc how to integrate this wit API REST or maybe you can add this code to API REST ?

Only downside for using the REST API is that in several months time it will be cycled out and we will be resorting to use Graph API whether it is fully completed or not.

Please go through this url:

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.