Created
November 14, 2012 13:26
-
-
Save deepakkumarnd/4072053 to your computer and use it in GitHub Desktop.
tweet using command line
This file contains hidden or 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
| #!/usr/bin/python | |
| # tweet-1.0 | |
| # @author deepakkumar | |
| # replace the user and passwd with your username and password | |
| # the log will be available in file tweetlog in the current directory | |
| import os | |
| import sys | |
| import time | |
| if len(sys.argv)!=2: | |
| print “Usage ./{0} <your tweet in double quotes>”.format(sys.argv[0]) | |
| quit(0) | |
| log=”tweetlog” | |
| tweet=sys.argv[1] | |
| user=”username” | |
| passwd=”pass” | |
| if not os.path.exists(log): | |
| logfile=open(log,”w”) | |
| else: | |
| logfile=open(log,”a”) | |
| _time=time.asctime() | |
| send_command=”curl -u {0}:{1} -d status=\”{2}\” http://twitter.com/statuses/update.xml -o /dev/null –progress-bar”.format(user,passwd,tweet) | |
| if os.system(send_command)==0: | |
| print(“successfully send”) | |
| logfile.writelines(_time+” “+tweet+”\n”) | |
| print(“log updated”) | |
| else: | |
| print(“sending failed”) | |
| logfile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment