@andypiper
Thanks for the reply. I tried the same but getting the same result:
{“errors”:[{“code”:200,“message”:“Forbidden.”}]}
The code now looks like this:
// twitter authentication
var twitter_oauth = {
consumer_key: nconf.get('TWITTER_CONSUMER_KEY'),
consumer_secret: nconf.get('TWITTER_CONSUMER_SECRET'),
token: nconf.get('TWITTER_ACCESS_TOKEN'),
token_secret: nconf.get('TWITTER_ACCESS_TOKEN_SECRET')
}
var WEBHOOK_URL = 'https://<domain>/webhook/twitter'
WEBHOOK_URL = WEBHOOK_URL.replace(/\!/g, "%21")
.replace(/\'/g, "%27")
.replace(/\(/g, "%28")
.replace(/\)/g, "%29")
.replace(/\*/g, "%2A");
// request options
var request_options = {
url: 'https://api.twitter.com/1.1/account_activity/all/env-beta/webhooks.json',
oauth: twitter_oauth,
headers: {
'Content-type': 'application/x-www-form-urlencoded'
},
form: {
url: WEBHOOK_URL
}
}
// POST request to create webhook config
request.post(request_options, function (error, response, body) {
console.log(body);
})