CodeIgniter Facebook integration
The official Facebook PHP SDK actually works fine with Codeigniter.
put base_facebook.php
and facebook.php
in your libraries
directory
create a facebook.php
file in your config directory with these contents
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');$config['appId'] = 'YOUR_APP_ID_HERE'; $config['secret'] = 'YOUR_APP_SECRET_HERE';
then use it like this
...$this->load->library('facebook');//Example usage from sdk exampleif ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $this->facebook->api('/me'); } catch (FacebookApiException $e) { error_log($e); $user = null; }}// Login or logout url will be needed depending on current user state.if ($user) { $logoutUrl = $this->facebook->getLogoutUrl();} else { $loginUrl = $this->facebook->getLoginUrl();}...
Full writeup here
but I'm less sure about importing profile data
Did you mean user profile data? If you want to get full user data (including email, birthday, etc), dont forget to ask user permission for that, in your oauth url, like...
$dialog_url = "http://www.facebook.com/dialog/oauth?client_id=" . $fb_app_id . "&redirect_uri=" . urlencode($fb_redirect_url) . "&scope=email,user_about_me,user_activities,user_interests,user_events,user_groups,user_birthday" . "&state=" . $facebook_csrf_state;