How to call an item from graph api fb?

Deadly 提交于 2019-12-11 23:56:36

问题


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?


回答1:


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

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


来源:https://stackoverflow.com/questions/18187165/how-to-call-an-item-from-graph-api-fb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!