Reputation: 57
I am using this code to get the posts of a page in api in javascript but it isn't working the FUNCTION FB.API IS NOT BEING INVOKED.
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxxxx',
xfbml : true,
version : 'v2.9'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function abdul(){
alert('working');
FB.api('EuropeanCommission/posts', GET, function(response) {
var output="<ul>";
for (var i in mydata.data) {
output+="<li>"+mydata.data[i].message;
}
output+="</ul>";
document.getElementById("placeholder").innerHTML=output; });
};
Upvotes: 0
Views: 443
Reputation: 362
You didn't put param field in your api call and GET should be in the single quote ' ':
FB.api('EuropeanCommission/posts', GET, function(response) {
});
You should do:
FB.api('EuropeanCommission/posts', 'GET', {} , function(response) {
});
Upvotes: 1