Welcome Guest, Not a member yet? Register   Sign In
Facebook PHP SDK v3.0.0 with CodeIgniter v2.0.2 - How to integrate?
#3

[eluser]Unknown[/eluser]
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
http://apps.facebook.com/facebook-ignited/

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:
Code:
<?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
Code:
$autoload['config'] = array('facebook');
6. In my controller after loading the "facebook" SDK library I can access it via $this->facebook:
Code:
$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:
Code:
$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.


Messages In This Thread
Facebook PHP SDK v3.0.0 with CodeIgniter v2.0.2 - How to integrate? - by El Forum - 05-24-2011, 06:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB