.. link: http://dgplug.org/summertraining/2013/posts/anurag619-tweetup-20130728.html .. description: .. tags: .. date: 2013/07/28 23:22:34 .. title: anurag619 tweetup 20130728 .. slug: anurag619-tweetup-20130728 tweetup ----------- A script will tweet along with a media file. `tweetup`_ code link. .. _tweetup: https://github.com/anurag619/mywork/tree/master/tweet/tweetup :: """the major modules imported here are: argparse and twython. twython retrieves and accesses twitter profile while argparse parses the option(file path and status)to tweet""" import sys import argparse from twython import Twython parser = argparse.ArgumentParser(description='this is a twitter script to post media with a descrition.') parser.add_argument('-f','--path/of/the/file', help='enter the file destination',required=True) parser.add_argument('-d','--status',help='enter your status', required=True) args = parser.parse_args() """the following credentials can be obtained from https://dev.twitter.com""" APP_KEY='your consumer key' APP_SECRET='your consumer secret' twitter = Twython(APP_KEY, APP_SECRET) auth = twitter.get_authentication_tokens() OAUTH_TOKEN = 'your Access token' OAUTH_TOKEN_SECRET = 'your token secret' twitter = Twython(APP_KEY, APP_SECRET,OAUTH_TOKEN,OAUTH_TOKEN_SECRET) photo = open(args.file, 'rb') twitter.update_status_with_media(status=args.status, media=photo) usage ------- to tweet with media file: $python tweetup -f location/to/image -d descrition