Using Account Activity API

oauth
webhooks

#1

Hi everyone,

I’m getting:

{"errors":[{"code":32,"message":"Could not authenticate you."}]}

while trying to create a webhook using https://api.twitter.com/1.1/account_activity/webhooks.json.

  • My app has Read, Write and Access direct messages permissions.
  • I regenerated the token after changing the permissions and I’m using the new one.
  • My webhook handler does not gets any hit

I’m using this script(create-webhook-config.js from twitter-webhook-boilerplate-node):

var request = require('request')

// twitter authentication
var twitter_oauth = {
  consumer_key: '0IuI...',
  consumer_secret: '18Be...',
  token: '2845...',
  token_secret: 'JcM...'
}

var WEBHOOK_URL = 'https://4ff464ad.ngrok.io'


// request options
var request_options = {
  url: 'https://api.twitter.com/1.1/account_activity/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)
})

Problem accessing account_activity web hooks
#2

Have you been granted access to the Account Activity API by using one of the links at https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/overview and providing your application ID from apps.twitter.com in the form?


#3

Hi Andy, Thanks for response.

Yes, I’ve been granted access for 30-days trial premium access and I’ve set the app from https://developer.twitter.com/en/dashboard


#4

@andypiper I wanna ask you one question as this thread is relevant. Is Account Activity API: All Activities got the full set of activities includes Tweets, @mentions , Replies, Retweets , Quote Tweets , Retweets of Quoted Tweets , Likes, Direct Messages Sent , Direct Messages Received , Follows , Blocks , Mutes , Typing indicators and Read receipts ? ref: https://developer.twitter.com/en/products/accounts-and-users/account-activity-api.html
I was looking here and it says only direct messages, https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/guides/receiving-events

FYI: I applied for getting the access.

Thanks


#5

Hi @0sman - the 30-day premium product you mentioned is a search product. Regardless, I do not see that you have a developer account set up with your @0sman handle. Are you using another @handle to access the developer portal?

@mnrahman I do not see that you applied for access to the All Activities version of the Account Activity API. Can you please be sure you apply here - https://developer.twitter.com/en/apply/user


#6

Hi KyleW, Thanks for your reply. I applied from our company twitter account which @cention. I’m really sorry to mention the account.
So basically if the application approved then we will get Account activity for all activities, right?

Thanks


#7

It looks like your account is pending - once the account is approved, we can help provision access to the Account Activity API. You will likely hear from someone about your application soon.


#8

@KyleW
We’re having the same issue with the API returning code 32, so we suspect that we don’t have access to the Account Activity API yet. But we’re also not able to apply:

When I click on https://developer.twitter.com/en/apply/user it redirects me to the Dashboard (https://developer.twitter.com/en/dashboard) and there it lists

  • Search Tweets: 30-Days / Sandbox
  • Search Tweets: Full Archive / Sandbox

Also can’t see any possibility besides those two at https://developer.twitter.com/en/account/subscriptions.

Is it true that this account has no access to Account Acitivity API?
Where else can we apply for Account Acitivity API?


#9

Hey @socialassiONE - It looks like the Account Activity API is not set up for your developer account. Which Client App would you like us to provide access for?


#10

For the App: “SocialHub by maloon” (5399622)

Thanks a lot!


#11

Hi @socialassiONE - we were able to provide access to the app you requested. Your environment name is: env-beta

Please be sure to check the documentation if you have any questions.


#12

Hello @KyleW
Can you please help in How do i know, whether i have access to Standard or Direct Message API thread…


#13

Hi,

I too have the same issue,
App name : MsgBox r139
App owner : @MsgboxD
environment label: msgdev

I am not able to register the webhook.


#14

What error are you seeing?


#15

Thank you for the response
this is the error showing.

{“errors”:[{“code”:32,“message”:“Could not authenticate you.”}]}


#16

@MsgboxD
Please make sure you have done the following:

  • You have an approved developer account.
  • You have set up a dev environment for the Account Activity API here.
  • You have set up your Twitter app’s Access token & access token secret access level is set to Read, Write, and Direct Messages. You can find this on the Keys and tokens tab of the app details/settings section. If it is not set to the proper access level, you must change the access level via the permissions tab of the app details/settings section and regenerate your access tokens.
  • Make sure you are using the proper app’s consumer keys and access tokens when registering your webhook URL. You can find which app you have attached to the Account Activity API by navigating to the “Dev Environments” page of the developer portal
  • Make sure you are using the proper :env_name in your request.

Please let me know if this helps you get past this error message. If it doesn’t, can you please provide the exact request that you are using to register your webhook URL?


#17

I have cross-checked the above mentioned points, still shows error.

I am using the following php wrapper for the twitter api v1.1 twitter-api-php .

please see the code:

<?php
$consumerkey        = '****';
$consumersecret     = '*****';
$accesstoken        = '********-********';
$accesstokensecret  = '********';

require_once('Classes/TwitterAPIExchange.php');

$settings = array(
  'oauth_access_token' => $accesstoken,
  'oauth_access_token_secret' => $accesstokensecret,
  'consumer_key' => $consumerkey,
  'consumer_secret' => $consumersecret
);

$url = 'https://api.twitter.com/1.1/account_activity/all/msgdev/webhooks.json?url=https://cii.emanantinc.com/r139c/twitterwebhook.php';
$requestMethod = 'POST';
$twitter = new TwitterAPIExchange($settings);

echo $twitter->buildOauth($url, $requestMethod)
    ->performRequest();

#18

Unfortunately I’m not too familiar with PHP nor that repository.

Another thing that has helped people previously is changing the “?” to “&” in your signature base string.


#19

Hi KyleW, Still didnt get the account approval. Is there any possibility for you to check?
It would be really grateful as we need it before 16th august as the site streams api gonna be deprecated.
Thanks


#20

Hey @mnrahman - It looks like we emailed asking for more information - please respond via email.