lodhb
lodhb

Reputation: 959

What is the best way to connect a Codeigniter project to the Facebook API?

What is the best way to make a Facebook app with Codeigniter?

I've seen fixes for using the official facebook-php-sdk, and libraries made for CI such as https://github.com/Necromnius/Facebook-Ignited/downloads

What should I consider before deciding the way forward?

Upvotes: 2

Views: 313

Answers (1)

Jon Winstanley
Jon Winstanley

Reputation: 23311

PHP SDK

The PHP SDK does not need a wrapper function anymore. It is fairly easy to implement and it means you do not need to another dependency. Also, the SDK is updated regularly, so you should ensure that your project is able to be updated easily. I.e. don't make any changes to the original facebook files, so that they can over written easily.

Knock together a simple library that includes the SDK files then connect to Facebook like so:

// Facebook
$facebook = new Facebook(array(
  'appId'  => $app_facebook_app_id,
  'secret' => $app_facebook_secret,
  'cookie' => $app_facebook_cookie,
));

if($facebook)
{
  // Get friends
  $facebook_friends = $facebook->api('/'.$facebook_id.'/friends');
}

foreach($facebook_friends as $facebook_friend)
{
  // Do something
}

Upvotes: 4

Related Questions