Wednesday, January 20, 2016

Using birdy to tweet a message

birdy makes it easy to tweet a message:

u:\20-birdy> tweet.py "Hello World!"

Here's the script (tweet.py):

import os import sys from birdy.twitter import UserClient if len(sys.argv) < 2: print "specify text to tweet" sys.exit() tweet_text = sys.argv[1] tw = UserClient(os.environ['TWITTER_CONSUMER_KEY' ], os.environ['TWITTER_CONSUMER_SECRET' ], os.environ['TWITTER_ACCESS_TOKEN' ], os.environ['TWITTER_ACCESS_TOKEN_SECRET']) tw.api.statuses.update.post(status = tweet_text)
Experimenting with the twitter API client birdy

tweet.py

birdy

No comments:

Post a Comment