Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
1 down vote favorite


I have this code right here, where the $friends variable is an array with an output like this:

{
  "id": "1149862205",
  "name": "name",
  "first_name": "first_name",
  "last_name": "last_name",
  "link": "https://www.facebook.com/username",
  "username": "username",
  "birthday": "07/12/1990",
  "hometown": {
    "id": "108618265828550",
    "name": "name"
  }, 

while $fbfriendlikes variable is generated by the id of $friends and has this structure :

{
  "data": [
    {
      "name": "Penelope-ns-test",
      "category": "Community",
      "id": "187099821418102",
      "created_time": "2012-06-14T15:00:59+0000"
    },

Now, I need to print all $friends ids which like a specific id in $fbfriendlikes My code goes like this:

$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));

        if ($fbfriendlikes["id"] != 184759054887922) {
            $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>';
            break;
        }
    }
}

I need to do a loop to get $fbfriendlikes[data][0][id] but i don't know how to do it..
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900