Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Write JSON data to a public store for saving state about a Bing Ads Script automation - for example to create virtual 'labels'
function main() {
// Enter your own URL here - get it from http://myjson.com
var MyJsonBin = 'https://api.myjson.com/bins/l46me';
// This is the object you will store for use the next time the script runs
var dataToStore = {};
dataToStore.lastKeywordProcessed = "some keyword";
dataToStore.someOtherThingToTrack = "the other thing's ID is 123456";
var options = {
method:"put",
payload:JSON.stringify(dataToStore),
contentType:"application/json",
};
var response = UrlFetchApp.fetch(MyJsonBin, options);
var responseText = response.getContentText();
var responseCode = response.getResponseCode();
Logger.log(responseText + " (" + responseCode + ")");
return;
var tokens = JSON.parse(response.getContentText());
var uri = tokens['uri'];
for(var key in tokens) {
var val = tokens[key];
Logger.log(key + " " + val);
}
Logger.log(uri);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.