A script will tweet along with a media file.
tweetup code link.
"""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)
to tweet with media file:
$python tweetup -f location/to/image -d descrition