Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading facebook wall feed JSON issues

I'm trying to load a facebook wall feed with jQuery on the client side of my website. The feed I'm using for the facebook request is:

http://www.facebook.com/feeds/page.php?format=json&id=40796308305

I've tried the following aproaches:

1.

$.getJSON('http://www.facebook.com/feeds/page.php?format=json&id=40796308305',function(data){
   console.log(data)

});

Which returns the error:

XMLHttpRequest cannot load http://www.facebook.com/feeds/page.php?format=json&id=40796308305. Origin http://xxxx.local is not allowed by Access-Control-Allow-Origin.

2.

$.ajax({
    url: 'http://www.facebook.com/feeds/page.php',
    type: 'GET',
    dataType: 'json',
    data: {
        id: '40796308305',
        format: 'json'
    },
    success: function(data, textStatus, xhr) {
        console.log(data);
    }
});

Returns the same error.

3.

$.ajax({
    url: 'http://www.facebook.com/feeds/page.php',
    type: 'GET',
    dataType: 'json',
    data: {
        id: '40796308305',
        format: 'jsonp'
    },
    success: function(data, textStatus, xhr) {
        console.log(data);
    }

});

Returns:

Uncaught SyntaxError: Unexpected token :

And seems to be parsing the feed.

How do I load the facebook json feed so that I can access it as i do an array?

like image 848
5442224 Avatar asked May 24 '26 04:05

5442224


1 Answers

You cannot do this with client-side only due to cross-domain policy restrictions.

You likely will need to create own proxy for that data (this endpoint for page data doesn't support JSONP and will not work with callback parameter)

like image 187
Juicy Scripter Avatar answered May 25 '26 16:05

Juicy Scripter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!