0

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;   });

};
3
  • Where do you call abdul? Commented Jun 14, 2017 at 13:34
  • when pressing button on simple html page Commented Jun 14, 2017 at 13:40
  • Please format the code properly. And then, as already advised in the FB developers group - check the browser console. Commented Jun 14, 2017 at 14:12

1 Answer 1

1

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) {      

    });
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.