How to add a Subscription to Account Activity API

webhooks
account-activity

#1

I am trying to subscribe to screen names for the Account Activity API. I have authenticated and registered the webhook. I tried to use lists/members/create to add to the subscription list. But, it seems that the specified user was saved in a member list of some kind instead. When I get with lists/subscriptions, I only see myself. Also, when I view the subscribers for the Account Activity API, I see 0.

I was interested in using ‘account_activity/all/:env_name/subscriptions’, but I did not see where to put a screen name.

After a lot of searching, I decided to ask here. How do I subscribe to a particular screen name for the Account Activity API? Thanks.


#2

Hi @SamJone73931958 - the Account Activity API is completely separate from the POST lists/members/create and GET lists/subscriptions endpoints. It is therefore not surprising that adding subscriptions did not work.

The former (Account Activity API) is a premium API. I suggest you read through our documentation and follow the steps outlined there to start adding subscriptions: https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/api-reference

The latter are two standard endpoints. I would also suggest reading through our documentation on GET lists/subscriptions and POST list/members/create if you are interested in using these. However, using these endpoints will have no impact whatsoever on the Accout Activity API.


#3

Thank you. I read through the documentation on adding subscriptions again located here: https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/api-reference. However, it is not clear to me where one would obtain SUBSCRIBING_USER’S_ACCESS_TOKEN for POST account_activity/all/:env_name/subscriptions. All I have is the user’s screen name for who I would like to subscribe. Can you please explain where/how SUBSCRIBING_USER’S_ACCESS_TOKEN is obtained? Thanks.


#4

@SamJone73931958 You need to have the user auth with your app (via oAuth) to obtain that token.


#5

Thank you. I have authenticated my app. So SUBSCRIBING_USER’S_ACCESS_TOKEN is my access token? Where does the screen name of the user that I am subscribing to come in?


#6

You need the access token for any user account(s) you want to have subscribe to your webhook. This means that you must have the user(s) sign-in to your application via the Sign-in With Twitter authorisation flow.

You cannot subscribe arbitrary users to your webhook without their permission or authentication - that would be a privacy issue, as you’d start to receive all of their activity - including Direct Messages, follows, etc - in real time at your webhook. So, ultimately, the screen name of the user that you’d like to subscribe to does not matter, the users themselves need to sign-in to your app in order to grant you access to their activities.

Our Account Activity API Dashboard sample demonstrates the moving parts, if you’re into node.js code.


#7

Thank you, I appreciate it. Your explanation and sample have been more helpful. After looking over the node.js sample and trying to implement it in PHP, there seems to be a large inconsistency among the subscriptions endpoint. The sample has completely different parameters than that of the associated documentation. What are the correct PHP parameters for the subscriptions endpoint?


#8

There is no such thing as “PHP parameters” for any endpoint. Endpoints are agnostic to the language used to invoke them.

PHP is a known tricky case because of how it encodes data. I would look at how exactly it’s sending data.


#9

Perhaps I did not phrase my question correctly. If you look at Andy’s example link with the add-subscription-other-user.js code, you will see that the subscriptions endpoint has parameters including an oauth array and resolveWithFullResponse boolean. However, if you look at the subscriptions endpoint’s documentation, there are no parameters and the header contains data. Seeing that these two endpoints pass in different data, what are the correct agnostic parameters for the subscriptions endpoint? Thanks.


#10

It’s possible the documentation is incorrect. That code however works as I use it all the time to manage subscriptions. I would take the code NodeJS sample as gospel in this case.


closed #11

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.