javascript - FB.api Response Is Undefined -
i'm developing website integrates facebook account display notes facebook account on website. after calling fb.api method response receive undefined , unable access 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 idea i'm going wrong? appreciated.
thanks.
if use console.log on response object, you'll realize includes "error" property , response.error.message "an access token required request resource."
you can check if response includes error using following:
function (response) { if (response.hasownproperty("error")) { alert("error: " + response.error.message); } else { //success! } } for error, similiar question can found here: "an access token required request resource" while accessing album / photo facebook php sdk
Comments
Post a Comment