I'm trying to pull id, gender, birthday, username, friends list and some other information about the user.
Heres my code:
if ($user) {
try {
$user_profile = $facebook->api('/me?fields=id, username, gender, birthday, friends', 'GET');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
The only thing is it only works when fields=id is the only parameter. Is there another way i should be doing this?
I have been working with the Facebook API today for my App and I managed to create a simple class, maybe this method will help you out.
public function getUserInfo($fields = null)
{
if($fields == null)
{
$fields = array('first_name','last_name','profile_update_time','current_location', 'sex', 'birthday', 'pic_square');
}
return $this->facebook->api_client->users_getInfo($this->fbUser, $fields);
}
Basically, $this->Facebook = new Facebook($this->apiKey, $this->secretKey);
and $this->fbUser = $this->facebook->getUser();
Hope this helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.