0

I'm trying to build a little google apps script to get some data from the Facebook Insight API. It's a total unfamiliar ground for me so I'm trying to build this step by step.

Until now I've only wrote the following script, I know it doesn't return anything but at last it should work so I can start asking for data :

function myFuntion() {  

window.fbAsyncInit = function() {
    FB.init({
      appId      : 'My_appid',
      xfbml      : true,
      version    : 'v2.1'
    });
  };

  (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 = "https://connect.facebook.net/en_US/all.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));

}

when I'm running this, I've the following error "window" is not defined.. What does it mean ? what do I have this error ?

thanks !

1 Answer 1

1

Possible duplicate

window is a reference to the browser window: This code snippet is intended more for use in a browser than in an Apps Script sample.

To make use of the API within Apps Script, you'll want to use UrlFetchApp to make requests.

The Facebook documentation shows examples for Curl which could be translated to the UrlFetchApp requests you need to make.

You'll need to generate an access token, which you'll need to include with the requests.

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

1 Comment

I've been reading multiple time the question you've mentioned but couldn't really understand.But your answer is really clear thank a lot.

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.