
Untitled
By: a guest on
Apr 18th, 2012 | syntax:
None | size: 1.45 KB | hits: 11 | expires: Never
How can I exclude an object from my array so a foreach loop avoids it?
{
"data": [
{
"name": "Person 1",
"id": "12345678",
"picture": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/123456789_123456_789456.jpg"
},
{
"name": "Person 2",
"id": "12345679",
"picture": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/123456789_123456_789457.jpg"
}
],
"paging": {
"next": "https://graph.facebook.com/me/friends?access_token=.....&fields=name,id,picture&limit=5000&offset=5000&__after_id=..."
}
}
$url = "https://graph.facebook.com/". $uid ."/friends?access_token=". $access_token ."&fields=name,id,picture";
$users = json_decode(file_get_contents($url));
echo $access_token .'<br><br>';
foreach ($users as $name => $value) {
foreach ($value as $entry) {
//Loop for profile pics
if ($entry->picture) {
echo '<a href="https://www.facebook.com/profile.php?id=' . $entry->id . '" target="_blank">' . '<img src="'. $entry->picture . '" class="profile-thumb' . $entry->name . '" id="'. $entry->id .'"></a>';
}
}
}
Notice: Trying to get property of non-object in C:inetpubwwwrootferef.comfacebooktest-appfriends.php on line 50
$data = $users->('data');
foreach($data as $entry){
if(isset($entry->picture)){
echo ...
}
}