I am trying to get the list of Twitter followers of a specific Twitter user using Google Apps Script. I found many sources:
but unable to create a link with my requirement. I have following code snippet:
function getFollowers(){
var twitterKeys = {
TWITTER_CONSUMER_KEY: '###',
TWITTER_CONSUMER_SECRET: '###',
TWITTER_ACCESS_TOKEN: '###',
TWITTER_ACCESS_SECRET: '###',
};
var username = 'Example name'
var props = PropertiesService.getUserProperties();
props.setProperties(twitterKeys);
var url = `https://api.twitter.com/2/users/${username}/followers`
var options = {
method: 'GET',
headers: {
api:twitterKeys
},
muteHttpExceptions: true
};
var response = UrlFetchApp.fetch(url, options);
var json = JSON.parse(response.getContentText());
console.log(json)
}
On runs, it shows following output:
{ "title": "Unauthorized", "type": "about:blank", "status": 401, "detail": "Unauthorized" }
Any advice would be much appreciated to resolve it and get Twitter followers of a specific Twitter user.