php - CodeIgniter Auth2 Library for Facebook Graph API : Not getting email address -


i new in facebook integration codeigniter.

i have done setup codeigniter oauth(0.3.1) , oauth2(0.3.1) library 'login facebook' functionality.

but not getting email address of fb user.

i getting name , id facebook.

i not able figure problem.

i 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);         }         // sending no options it'll come 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 me.

thanks

the way users e-mail address request extended permissions on email field. user must allow see , cannot e-mail addresses of user's friends.

http://developers.facebook.com/docs/authentication/permissions

you can if using facebook connect passing scope=email in string of call auth dialog.

i'd recommend using sdk instead of file_get_contents makes far easier perform oauth authentication.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -