Tag Archives: SDK
So I searched all over the net and couldn’t really find the answer to a simple question… how do you integrate Facebook’s PHP SDK AS IS as a Library in CodeIgniter?
There are a lot of great libraries out there that add their own functionality as well as integrate, but it’s not something I was looking to do really.. the default functionality was enough.
Anyway here’s how to do this. first go here:
download the latest version and upload the 3 files facebook.php base_facebook.php and fb_ca_chain_bundle.crt to your application/libraries/ directory.
Now rename facebook.php to Facebook.php
Now create a file in your application/config/ folder called: facebook.php
in this file you should have the following:
< ?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); $config['appId'] = 'your_app_id'; $config['secret'] = 'your_app_secret'; $config['canvas'] = true;
Ok now save that file and open up in that same dir (application/config/) open: autoload.php and then look for: $autoload['libraries']
Add to this array ‘facebook’ so it should look like this:
$autoload['libraries'] = array('database','session','facebook');
Do keep in mind that in this case I am also loading the database and session libraries.
Once you do this, you can simply call $this->facebook to access your Facebook Library Class.
Note: DO NOT add facebook to $autoload['config'] = array();
I made this mistake and took me some time trying to figure out why it wasn’t working properly.