Going over the Facebook API and I\'m a bit confused on the right approach. I want users to skip registration, or auto-register them if they sign in with Facebook. So if th
I suggest you read the framework documentation. Adding a library to CodeIgniter is not a hard task. And Facebook library is no exception.
Here's a quick integration I've just come up with:
1.create a config file:application/config/facebook.php
2.place the sdk files in the libraries folder application/libraries/ and rename the facebook.php file to Facebook.php and replace the php tag with this:
3.in your controller load the config file and then load the Facebook library:
config->load("facebook",TRUE);
$config = $CI->config->item('facebook');
$this->load->library('facebook', $config);
}
public function index()
{
$user = $this->facebook->getUser();
if($user) {
try {
$user_info = $this->facebook->api('/me');
echo ''.htmlspecialchars(print_r($user_info, true)).'
';
} catch(FacebookApiException $e) {
echo ''.htmlspecialchars(print_r($e, true)).'
';
$user = null;
}
} else {
echo "facebook->getLoginUrl()}\">Login using Facebook";
}
}
}
Now in the constructor method, you have just initialized the Facebook library (sdk) and it can be accessed by using: $this->facebook.
Notes: