I’m developing a website which integrates with a facebook account to display the notes from the facebook account on the website. However after calling the FB.api method the response I receive is undefined and I am unable to access the data in ‘response.data’.
Test
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
window.fbAsyncInit = function()
{
FB.init({appId: '12345678', status: true, cookie: true, xfbml: true});
FB.api (
'/pagename/notes',
function(response)
{
alert(response.data.length);
}
);
};
</script>
</body>
Has anyone any idea where I’m going wrong? Any help would be much appreciated.
Thanks.
If you use
console.logon the response object, you’ll realize that it includes an “error” property and thatresponse.error.messageis “An access token is required to request this resource.“You can check if your response includes an error by using the following:
For the error, a similiar question can be found here: "An access token is required to request this resource" while accessing an album / photo with Facebook php sdk