Skip to content

Instantly share code, notes, and snippets.

@deploytoprod
Last active November 3, 2019 15:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deploytoprod/67197d3ac4e4819bbe4e5d42c8331990 to your computer and use it in GitHub Desktop.
Save deploytoprod/67197d3ac4e4819bbe4e5d42c8331990 to your computer and use it in GitHub Desktop.
from requests_oauthlib import OAuth1Session
import urllib
CONSUMER_KEY = 'AAA'
CONSUMER_SECRET = 'BBB'
ACCESS_TOKEN = 'CCC'
ACCESS_SECRET = 'DDD'
# Above I put credentials for the App 'TwitterBoxRaf', App ID '16265219'
twitter = OAuth1Session(CONSUMER_KEY,
client_secret=CONSUMER_SECRET,
resource_owner_key=ACCESS_TOKEN,
resource_owner_secret=ACCESS_SECRET)
webhook_endpoint = urllib.parse.quote_plus('My AWS API Gateway endpoint here')
url = 'https://api.twitter.com/1.1/account_activity/all/prod/webhooks.json?url={}'.format(webhook_endpoint)
r = twitter.post(url)
# In Twitter web settings, the app 'TwitterBoxRaf' is associated with the env called 'prod'
r = twitter.post(url)
print(r.json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment