{"id":506,"date":"2022-08-30T15:02:29","date_gmt":"2022-08-30T15:02:29","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/access-facebook-json-reponse-object-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:02:29","modified_gmt":"2022-08-30T15:02:29","slug":"access-facebook-json-reponse-object-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/access-facebook-json-reponse-object-collection-of-common-programming-errors\/","title":{"rendered":"Access facebook json reponse object-Collection of common programming errors"},"content":{"rendered":"<p>I have an json reponse from facebook like this picture. <img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/5T5oB.png\" \/><\/p>\n<p>This is the way i tried to access the likes count <code>data.posts.data[0].likes.count<\/code> but it kept showing undefined error and i also tried to access comments object like this <code>data.posts.data[0].comments.length<\/code> it showed the same error. I am stuck here anyone could help me out?<\/p>\n<p>This is my used code to get json<\/p>\n<pre><code>var fburl = \"https:\/\/graph.facebook.com\/128618520547487\/?fields=posts.fields(picture,comments,likes,source,link,message)&amp;access_token=CAACEdEose0cBAFOZAdI3zIOmKwkCi2tUZCAl2tpuIyh3WuE5B4njTviyzk4msgZCnKBVTNuXh2FQTf4XkfatgVHYer43TTw2kqV2vxHsjNbjbjiUPKToBrCpUP6ZBhVbr00GQTqjcCynzdGHHObe8OwYK7UMXLcZD\";\n      var data;\n      $('.home-blog').append('<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-09 20:01:53. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I have an json reponse from facebook like this picture. This is the way i tried to access the likes count data.posts.data[0].likes.count but it kept showing undefined error and i also tried to access comments object like this data.posts.data[0].comments.length it showed the same error. I am stuck here anyone could help me out? This is [&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-506","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/506","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=506"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/506\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}