Facebook Graph API parse JSON feed with PHP-Collection of common programming errors

I am trying to use php to parse a JSON feed of posts using Facebook Graph API

I found the following solution for comments…


This is the url id I’m working with: https://graph.facebook.com/210849652406/feed/?access_token={VALID_USER_TOKEN}

I just don’t know how to call the items for this feed. I’m trying to make the comments parse with this post/feed but I get essentially nothing. I want the basic items like name of the post, caption, etc. I think if I just could get the name of the post I could figure it all out!

  1. You are looping incorrectly

    try this

    foreach($fb_response->data as $item){
    echo 'Message: ' . $item->message . '
    ';//there is no name returned on a comment echo 'From ID: ' . $item->from->id . '
    '; echo 'From Name: ' . $item->from->name . '
    '; echo 'Message: ' . $item->message . '
    '; echo 'Timestamp: ' . $item->created_time . '

    '; }
  2. Do you have warnings/errors displayed? Ensure that you have extension=php_openssl.dll (or .so) enabled in your php.ini or you will get no results. This is because you are fetching from a secure site.

    Also $item->name is an undefined property in the JSON. Perhaps you mean $item->id. Everything else looks ok.

Originally posted 2013-11-09 19:26:05.