{"id":423,"date":"2022-08-30T15:01:06","date_gmt":"2022-08-30T15:01:06","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/facebook-graph-api-parse-json-feed-with-php-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:01:06","modified_gmt":"2022-08-30T15:01:06","slug":"facebook-graph-api-parse-json-feed-with-php-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/facebook-graph-api-parse-json-feed-with-php-collection-of-common-programming-errors\/","title":{"rendered":"Facebook Graph API parse JSON feed with PHP-Collection of common programming errors"},"content":{"rendered":"<p>I am trying to use php to parse a JSON feed of posts using Facebook Graph API<\/p>\n<p>I found the following solution for comments&#8230;<\/p>\n<pre><code>\n<\/code><\/pre>\n<p>This is the url id I&#8217;m working with: https:\/\/graph.facebook.com\/210849652406\/feed\/?access_token={VALID_USER_TOKEN}<\/p>\n<p>I just don&#8217;t know how to call the items for this feed. I&#8217;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!<\/p>\n<ol>\n<li>\n<p>You are looping incorrectly<\/p>\n<p>try this<\/p>\n<pre><code>foreach($fb_response-&gt;data as $item){\necho 'Message: ' . $item-&gt;message . '<br \/>';\/\/there is no name returned on a comment\necho 'From ID: ' . $item-&gt;from-&gt;id . '<br \/>';\n echo 'From Name: ' . $item-&gt;from-&gt;name . '<br \/>';\n echo 'Message: ' . $item-&gt;message . '<br \/>';\n echo 'Timestamp: ' . $item-&gt;created_time . '<br \/><br \/>';\n}\n<\/code><\/pre>\n<\/li>\n<li>\n<p>Do you have warnings\/errors displayed? Ensure that you have <code>extension=php_openssl.dll<\/code> (or <code>.so<\/code>) enabled in your php.ini or you will get no results. This is because you are fetching from a secure site.<\/p>\n<p>Also <code>$item-&gt;name<\/code> is an undefined property in the JSON. Perhaps you mean <code>$item-&gt;id<\/code>. Everything else looks ok.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 19:26:05. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I am trying to use php to parse a JSON feed of posts using Facebook Graph API I found the following solution for comments&#8230; This is the url id I&#8217;m working with: https:\/\/graph.facebook.com\/210849652406\/feed\/?access_token={VALID_USER_TOKEN} I just don&#8217;t know how to call the items for this feed. I&#8217;m trying to make the comments parse with this post\/feed [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-423","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/423","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=423"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/423\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}