Reading feed using JavaScript SDK

I am attempting to retrieve a user's news feed using the JavaScript SDK. This works fine in the Test Console but as soon as I try it on my site it doesn't work.

FB.api('/me/home', 'get', function(response) {
  if (!response || response.error) {
    alert('Error occured');
  } else {
    alert(response);
  }
});

I understand that the alert will just return "[object]" but I'm just trying to get the API call working right now. Any help would be greatly appreciated

Answers


Are you asking the user for the read_stream permission. You can't see the user's feed without that permission. That could be the reason for the error.

Alert the actual error to make debugging easier:

alert( response.error );

Or even better, use console.log:

FB.api('/me/home', 'get', function(response) {
  console.log(response);
});

Calling your function too early could be causing the call to fail. Try wrapping your function in the fbAsycInit function:

window.fbAsyncInit = function() {
    FB.api('/me/home', 'get', function(response) {
        console.log(response);
    });
};

Need Your Help

xmlrpclib error 'module not found' when trying to access gandi api

python api python-3.x xml-rpc

I am trying to set the DS record in the gandi api as describded in the gandi api support doc

Corner detection in an array of points

python numpy computer-vision point-clouds corner-detection

I get a pointcloud from my lidar which is basically an numpy array of points in 2D cartesian coordinates. Is there any efficient way to detect corners formed by such 2D points?