I am using facebook graph api to access mutual friend list using PHP Here's how I am doing it
$url = "https://graph.facebook.com/me/mutualfriends/123456788?access_token=1457856"; $user = json_decode(file_get_contents($jsonurl));
I am now printing the result via print_r($user->data) and following is the output
Array ( [0] => stdClass Object ( [name] => XYZ [id] => 123 ) ) Array ( [0] => stdClass Object ( [name] => YZX [id] => 235 ) )
I need to get name and Id of the mutual friends from the above resultset using PHP
What should be the next step for this?
It would be the same like $user->data
:
foreach($user->data as $user) {
echo "name: ".$user->name."<br>";
echo "id: ".$user->id."<hr>";
}
I have tested this on the following data:
stdClass Object
(
[data] => Array
(
[0] => stdClass Object
(
[id] => ID
[name] => Name
)
[1] => stdClass Object
(
[id] => ID
[name] => Name
)
)
)
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.