Hey all,
A week ago I started working with Account Activity API, already got access in January.
I’ve had almost every possible error: 261, 89, 215
EDIT:
I found this Node JS version, everything works just fine with that, i test it out and im able to set the webhook up.
I tried to rewrite the same call in ruby but i just canno get it working there, anyone who has done it?
GITHUB - twitterdev/twitter-webhook-boilerplate-node
**/helpers/auth.js**
auth.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')
}
auth.twitter_webhook_environment = nconf.get('TWITTER_WEBHOOK_ENV')
**/routes/webhook.js**
var request_options = {
url: 'https://api.twitter.com/1.1/account_activity/all/' + auth.twitter_webhook_environment + '/webhooks.json',
oauth: auth.twitter_oauth,
headers: {
'Content-type': 'application/x-www-form-urlencoded'
},
form: {
url: req.body.url
}
}
return request.post(request_options)
This is my ruby version, what do i forgetting there?
oauth = {
consumer_key: ENV["TW_CONSUMER_KEY"],
consumer_secret: ENV["TW_CONSUMER_SECRET"],
token: ENV["TW_CONSUMER_KEY"],
token_secret: ENV["TW_CONSUMER_SECRET"]
}
url = "https://api.twitter.com/1.1/account_activity/all/env-beta/webhooks.json"
body = "url=https://29a44f00.ngrok.io/twitter/webhook"
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": oauth
}
response = HTTParty.post(url, body: body, headers: headers)
I also tried to to run auth with "Authorization": "Bearer token" trough /oauth2/token request, but that also didn’t worked.
Thanks a lot for any help and suggestions. @andypiper