Facebook API batch request with Google Apps Script -


i'm struggling building batch request in apps script change multiple facebook ad set budgets in 1 api call.

facebook gives me following example (curl):

curl -f 'access_token=____'      -f 'batch=[                {                 "method": "post",                 "relative_url": "<api_version>/6004251715639",                 "body": "redownload=1&bid_info={\"clicks\":100}"                },                {                 "method": "post",                 "relative_url": <api_version>/v6004251716039",                 "body": "redownload=1&bid_info={\"clicks\":100}"                },                {                 "method": "post",                 "relative_url": "<api_version>/6004251715839",                 "body": "redownload=1&bid_info={\"clicks\":100}"                }               ]' https://graph.facebook.com 

my code in apps script following:

function testbatchrequest() {    var url = "https://graph.facebook.com/v2.3/?access_token=xxx",         batch=[                 {                 "method": "post",                 "relative_url": "/<ad set id>",                 "body": "redownload=1&daily_budget=25000"                },                {                 "method": "post",                 "relative_url":"/<ad set id>",                 "body": "redownload=1&daily_budget=25000"                }];    url = url + "&batch=" + json.stringify(batch);   logger.log(url);    var options = {       "method": 'post',       "followredirects" : true,       "mutehttpexceptions": true   };    var result = urlfetchapp.fetch(url, options);     var json = result.getcontenttext();   var data = json.parse(json);    logger.log(json);   logger.log(data);  } 

as response "invalid argument".

to asnwer potential sdk question: haven't found working way integrate javascript sdk in app script.

it's first time me working batch requests , still consider myself beginner. appreciated. thanks


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -