-
-
Save ianmas-aws/d2ebd1b81ad74f5c2c9ea92e40bd881a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from requests_oauthlib import OAuth1Session | |
import os | |
CONSUMER_KEY = os.getenv("CONSUMER_KEY") | |
CONSUMER_SECRET = os.getenv("CONSUMER_SECRET") | |
ACCESS_KEY = os.getenv("ACCESS_KEY") | |
ACCESS_SECRET = os.getenv("ACCESS_SECRET") | |
twitter = OAuth1Session( | |
CONSUMER_KEY, | |
client_secret=CONSUMER_SECRET, | |
resource_owner_key=ACCESS_KEY, | |
resource_owner_secret=ACCESS_SECRET | |
) | |
base_url = "https://api.twitter.com/1.1/" | |
r = twitter.post(base_url+"account_activity/webhooks.json", params={'url': "https://api.ranman.com/twitter/webhook"}) | |
r.raise_for_status() | |
webhook_id = r.json()['id'] | |
resp = twitter.post(base_url+"account_activity/webhooks/{}/subscriptions.json".format(webhook_id)) | |
print(resp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment