Search code examples
twittertwitterapi-python

what is the twurl command for triggering the twitter challenge response check (crc) for the invalid webhook id to make it valid again?


I registered my webhook url successfully, but as my server slept and i missed the twitter crc check which occurs in every 24 hours, due to which my webhook id became invalid. From the documentation i found the following curl command

curl --request PUT 
--url https://api.twitter.com/1.1/account_activity/webhook/:WEBHOOK_ID.json --header 
 'authorization: OAuth oauth_consumer_key="CONSUMER_KEY",oauth_nonce="GENERATED", oauth_signature="GENERATED", oauth_signature_method="HMAC-SHA1", oauth_timestamp="GENERATED", oauth_token="ACCESS_TOKEN", oauth_version="1.0"'

but I don't know how to generate oauth_nonce, oauth_signature. So i thought using Twurl which handles oauth 1.0 easily.

Does anyone knows the twurl command to do trigger the crc check for twitter?

Or does anyone knows the code for generating oauth_nonce and oauth_signature in python3?


Solution

  • That documentation is incorrect (where did you find it?), but I can help you.

    If you have twurl set up correctly, authenticated with the correct consumer key and secret that your webhook app is using and with the user ID you're using with it, then this command should work (I just tried it here and it works for me)

    twurl -X PUT "/1.1/account_activity/all/:ENV-NAME/webhooks/:WEBHOOK_ID.json"

    So in my case, with an environment name of env-beta and a known webhook ID, this triggered the CRC check:

    twurl -X PUT "/1.1/account_activity/all/env-beta/webhooks/10656zzzzMYIDzzz35232.json"