I have this code right here, where the $friends
variable is an array with an output like this:
{
\"id\": \"1149862205\",
\"name\": \"name\",
Try this:
$return = '';
$friends = $facebook->api('/me/friends');
if (!empty($friends['data'])) {
$size = variable_get('facebook_graph_pic_size_nodes','square');
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
foreach ($friends['data'] as $data) {
$fbid = $data['id'];
$fbfriendlikes[$fbid]=$facebook->api('/'.$fbid.'/likes');
$fbname = $data['name'];
$path = $protocol . '://graph.facebook.com/' . $fbid . '/picture?type=' . $size;
$image = theme('image', array('path' => $path, 'alt' => $fbname));
$likes = false;
foreach($fbfriendlikes['data'] as $like) {
if($like['id'] == '184759054887922') { // maybe $like->id will have to be used instead...
$likes = true;
break;
}
}
if (!$likes) {
$return .= '<div class="fimage">'.$image.'</div>';
$link = '<a href="'.$protocol . '://www.facebook.com/profile.php?id='.$fbid.'" target="_blank">'.$fbname.'</a>';
$return .= '<div class="flink">'.$link.'</div>';
}
}
echo $return;
}
You need to check inside you loop to get the ones that don't like.
$return = '';
$friends = $facebook->api('/me/friends');
if (!empty($friends['data'])) {
$size = variable_get('facebook_graph_pic_size_nodes','square');
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
foreach ($friends['data'] as $data) {
$fbid = $data['id'];
$fbfriendlikes[$fbid]=$facebook->api('/'.$fbid.'/likes');
$fbname = $data['name'];
$path = $protocol . '://graph.facebook.com/' . $fbid . '/picture?type=' . $size;
$image = theme('image', array('path' => $path, 'alt' => $fbname));
foreach($fbfriendlikes['data'] as $like) {
$likes = false; // set var to check for like
if($like['id'] == '184759054887922') { // check if they liked it
$likes = true; // set var to true because they liked it
}
if (!$likes) { // test var to see if false (they did not like)
// print this if they did NOT like it, otherwise do nothing
$return .= '<div class="fimage">'.$image.'</div>';
$link = '<a href="'.$protocol . '://www.facebook.com/profile.php?id='.$fbid.'" target="_blank">'.$fbname.'</a>';
$return .= '<div class="flink">'.$link.'</div>';
}
}// go on to next in loop
}
echo $return;
}