get facebook page feed as json with jquery

纵饮孤独 提交于 2019-12-18 01:14:42

问题


I have been trying to get facebook page feed from json data with jquery. so far I have been able to get page details with my method but when I try to get page's feed it gives me an error and in the console it says "syntax error: invalid label". this is my code.....

    $.getJSON("https://www.facebook.com/feeds/page.php?id=237173582992285&format=json&callback=?", function(results){
    console.log(results);
});

I also have created a jsfiddle with the whole code. check it out if required -> http://jsfiddle.net/yZn7N/. I can see all the json data if I go to the specified link and they do get fetched and I'm not sure what's causing the invalid label error. Any kind of help fixing it or explanation of why this is happening will be gratefully appreciated.


回答1:


You need to use the Facebook Graph API for this to happen.

https://developers.facebook.com/docs/reference/api/page/#feed

Your call should change to:

https://graph.facebook.com/237173582992285/feed?access_token=YOUR-TOKEN-GOES-HERE

You can try use this test page and try to familiarize with the graph api.

https://developers.facebook.com/tools/explorer/?method=GET&path=237173582992285%2Ffeed

EDIT:

You can also get the Wall from the page in several formats.

JSON https://www.facebook.com/feeds/page.php?format=json&id=237173582992285

ATOM https://www.facebook.com/feeds/page.php?format=atom10&id=237173582992285

RSS https://www.facebook.com/feeds/page.php?format=rss20&id=237173582992285




回答2:


Get rid of &callback=? from your URL. You have a result handler as part of your function. You don't need a callback.

This should give you the result you are looking for, but it appears that Facebook is blocking jsfiddle via an .htaccess policy.



来源:https://stackoverflow.com/questions/11926659/get-facebook-page-feed-as-json-with-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!