I am new in facebook integration with codeigniter.
I have done all setup for codeigniter oauth(0.3.1) and oauth2(0.3.1) library for 'Login with facebook' functionality.
But I am not getting email address of fb user.
I am getting only name and id from facebook.
I am not able to figure the problem.
I am using following code of CI
public function oauth2($providername)
{
$key = $this->config->item('key',$providername);
$secret = $this->config->item('secret',$providername);
$this->load->helper('url_helper');
$this->load->spark('oauth2/0.3.1');
$provider = $this->oauth2->provider($providername, array(
'id' => $key,
'secret' => $secret,
));
//var_dump($provider);
if ( ! $this->input->get('code'))
{
if($providername =='facebook'){
$url = 'http://example.com'.$provider->redirect_uri;
redirect($url);
}
// By sending no options it'll come back here
$provider->authorize();
}
else
{
// Howzit?
// echo "in else";die;
try
{
$token = $provider->access($_GET['code']);
$user = $provider->get_user_info($token);
print_r($user);die;
$this->saveData($providername,$token,$user);
}
catch (OAuth2_Exception $e)
{
show_error('That didnt work: '.$e);
}
}
}
Please Help me.
Thanks