Facebook Graph API parse JSON feed with PHP
You are looping incorrectly
try this
foreach($fb_response->data as $item){echo 'Message: ' . $item->message . '<br />';//there is no name returned on a commentecho 'From ID: ' . $item->from->id . '<br />'; echo 'From Name: ' . $item->from->name . '<br />'; echo 'Message: ' . $item->message . '<br />'; echo 'Timestamp: ' . $item->created_time . '<br /><br />';}
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.
Why aren't you using the PHP SDK?