douzhao2047 2013-08-12 12:35
浏览 44
已采纳

如何从图表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?

  • 写回答

1条回答 默认 最新

  • dongta5747 2013-08-12 12:44
    关注

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

    $getcm = $getlike['data'][0]['like_info']['user_likes'];
    echo $getcm;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?