Facebook how to get a friends_hometown?
I am using FB graph v3 and i already 开发者_如何学编程ask for permission to friends data. But when i try to get access it won't return any value for hometown
my permission array 'scope' => 'offline_access,publish_stream,user_birthday,user_location,user_about_me,user_hometown, friends_hometown, friends_location'
if ($user){ //get user basic description $userInfo = $facebook->api("/$user"); //print_r($userInfo); try{
$friends = $facebook->api("/$user/friends");
// echo $friends->('friends_hometown');
print_r($friends->data);
}
Returned is: Array ( [0] => stdClass Object ( [name] => Jim Wel [id] => 100001572804563 ) )
How can i get friends_hometown friends_location???
regards
Not sure exactly how the Facebook SDK works since I wrote my own, but id it returns the JSON properly this should work:
$friends = $facebook->api('/me/friends');
for($i = 0; $i < count($friends); $i++){
$friend = $facebook->api('/'.$friends[$i]->id);
echo $friend->hometown->name.'<br />';
}
Remember to request permissions "friends_hometown" too.
精彩评论