简体   繁体   中英

How to call an item from graph api fb?

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?

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

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

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM