Search code examples
jqueryfacebook-graph-apijsonp

get facebook page feed as json with jquery


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.


Solution

  • 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