php - Facebook API - Get friends hometown -
php - Facebook API - Get friends hometown -
im looking retrieve of friends hometowns, using similar php used retrieve names. think code im using should work think because users havent set hometown wont work , says each argument invalid (although wrong).
when typing in url web browser next structure:
{ "id": "z", "friends": { "data": [ { "name": "x", "hometown": { "id": "x", "name": "x" }, "id": "x" },
which repeated every user in friend list, although friends without hometown next omitted:
"hometown": { "id": "x", "name": "x" },
to retrieve name , birthday have used next php:
$response2 = curl_exec($ch2); $user2 = json_decode($response2, true); $user3=$user2{'friends'}; $user4=$user3['data']; echo ("<h2>friend list</h2><br>"); foreach($user4 $friend) { echo $friend["name"] . "<br />" . $friend["birthday"] . "<br /><br />"; } }
ps know variable names arent particularly alter them 1 time ive figured out im doing hometown!
thanks lot help in advance.
not makes hometown or location available friends. in case won't able info on api , need check that.
to bit more info querying hometown, read out current_location.
through graph api utilize resource: https://graph.facebook.com/me/friends?fields=hometown,location
if using fql can utilize query this:
select uid, first_name, last_name, current_location, hometown_location, friend_count, mutual_friend_count user uid in (select uid2 friend uid1 = me())
remember need friends_location
, friends_hometown
permission read these fields.
php facebook facebook-graph-api
Comments
Post a Comment