Skip to content

Instantly share code, notes, and snippets.

@redavis22
Forked from ranman/lambda_function.py
Created February 5, 2017 05:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save redavis22/2653169feaa66e7ef2bd912a2c0aed75 to your computer and use it in GitHub Desktop.
Save redavis22/2653169feaa66e7ef2bd912a2c0aed75 to your computer and use it in GitHub Desktop.
  1. Create the lambda function with daily trigger
  2. goto https://apps.twitter.com/
  3. Create a new app
  4. In keys and access tokens for the new app click "create access token"
  5. Fill in the values here
import datetime
import requests
from requests_oauthlib import OAuth1
auth = OAuth1(
'consumer',
'consumer_secret',
'auth',
'auth_secret'
)
reinvent = datetime.date(2016, 11, 28)
today = datetime.date.today()
diff = reinvent - today
status = """\
Only {} days until @AWSreInvent #RoadToReInvent!! https://reinvent.awsevents.com/
""".format(diff.days)
def lambda_handler(event, context):
resp = requests.post(
"https://api.twitter.com/1.1/statuses/update.json",
data={'status': status},
auth=auth
)
resp.raise_for_status()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment