0

I want to select an specific field.item from the requested api call and echo it.for example something like this:

$getlike = $facebook->api("/fql?q=SELECT%20like_info%20FROM%20stream%20WHERE%20post_id=".$id);

$getcm = $getlike['data']['like_info']['user_likes'];
echo $getcm;

The JSON for the above code:

{
  "data": [
    {
      "like_info": {
        "can_like": true, 
        "like_count": 70, 
        "user_likes": false
      }
    }
  ]
}

When i echo the $getcm,it wont return anything.Is there anything wrong?

Daniel_dever
  • 39
  • 1
  • 6

1 Answers1

0

data is an array; so you should fetch it like-

$getcm = $getlike['data'][0]['like_info']['user_likes'];
echo $getcm;
Sahil Mittal
  • 20,697
  • 12
  • 65
  • 90
  • $getlike = $facebook->api("/fql?q=SELECT like_info FROM stream WHERE post_id=" . $id); $checklike = $getlike['data'][0]['like_info']['user_likes']; It does not return anything. – Daniel_dever Aug 12 '13 at 12:55
  • Blank do you mean? If yes, pls check if you have the permission: `read_stream` – Sahil Mittal Aug 12 '13 at 13:03
  • https://docs.google.com/file/d/0B63GOnae39s1YWZrZkJJbWE2ZUk/edit?usp=sharing As you can see i already checked the permission.but still no result at all. :( – Daniel_dever Aug 12 '13 at 15:59
  • You dont have to set the permissions here, but in the code. Check the answer here: http://stackoverflow.com/questions/18200251/json-api-graph-call-does-not-return-anything/18200619#18200619 – Sahil Mittal Aug 13 '13 at 04:27
  • HELP PLEASE! http://stackoverflow.com/questions/18215412/how-can-i-like-an-post-using-graph-api – Daniel_dever Aug 13 '13 at 17:30