php - Only Getting User Name and ID -


i using codeigniter , implementing facebook php sdk website user able login into.

eveything went well, don't know why able name , id.

here code library i've got somewhere:

public function login_url() {   return $this->helper->getloginurl( $this->permissions ); }  /**  * returns current user's info array.  */ public function get_user() {   if ( $this->session ) {     /**      * retrieve userĂ¢€™s profile information      */     // graph api request user data     $request = ( new facebookrequest( $this->session, 'get', '/me' ) )->execute();      // response array     $user = $request->getgraphobject()->asarray();      return $user;   }   return false; } 

and here controller:

fisrt direct website facebook

public function index() {     $this->load->library('facebook');     redirect($this->facebook->login_url()); }    

and facebook redirect website (myweb.com/index.php/getuser)

public function getuser() {      $this->load->library('facebook');     $user = $this->facebook->getuser();      echo "<pre>";     print_r($user);   }    

however result only:

array (     [name] => iyal     [id] => 143426842340043 ) 

my question is, how full information of user, such email address, profil picture, , etc.

thanks in advance.

by default when retrieving user's profile via facebook api limited set of fields returned such ones getting.

you must include fields wish information in request graph api. list of profile fields available here.

what need add these additional fields request made in library using method demonstrated here.

for instance in situation if wanted user's email address in addition standard data add method in library:

public function get_userwithemail() {     if ( $this->session ) {     /**     * retrieve userĂ¢€™s profile information     */     // graph api request user data     $request = ( new facebookrequest( $this->session, 'get', '/me?fields=id,name,email' ) )->execute();      // response array     $user = $request->getgraphobject()->asarray();      return $user;   }   return false; } 

please note version of api library targets old version. may better off rewriting work latest version ensure supported future. documents here give pretty overview , should obvious enough parts of library change whilst retaining original structure.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -