function run() {
var service = getService();
if (service.hasAccess()) {
var url = '
https://ads-api.twitter.com/11/accounts/18ce54jfg34/audience_estimate';
var payload = {
"targeting_criteria": [{
"targeting_type": "LOCATION",
"targeting_value": "96683cc9126741d1"
},
{
"targeting_type": "BROAD_KEYWORD",
"targeting_value": "cats"
},
{
"targeting_type": "SIMILAR_TO_FOLLOWERS_OF_USER",
"targeting_value": "14230524"
},
{
"targeting_type": "SIMILAR_TO_FOLLOWERS_OF_USER",
"targeting_value": "90420314"
}
]
};
var response = service.fetch(url, {
method: 'post',
payload: payload, // also tried with JSON.stringify(payload)
headers:{
"Content-Type":"application/json"
},
"muteHttpExceptions":true
});
var result = JSON.parse(response.getContentText());
Logger.log (JSON.stringify(result, null, 2));
} else {
var authorizationUrl = service.authorize();
Logger.log (authorizationUrl);
}
}