Permalink
Browse files

quick script to allow *posting* to twitter. it's about time!

  • Loading branch information...
1 parent c1548f7 commit 5ba92aa4a81c551213a23053b701554b5f18e420 Hilary Mason committed Aug 29, 2010
Showing with 41 additions and 0 deletions.
  1. +41 −0 w.py
View
41 w.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+# encoding: utf-8
+"""
+w.py
+
+Created by Hilary Mason on 2010-08-21.
+"""
+
+import sys, os
+from optparse import OptionParser
+import pickle
+
+import tweepy
+
+import settings
+from lib import mongodb
+
+
+class writeTweet(object):
+ def __init__(self, options, args):
+ if options.debug:
+ print options
+ print args
+
+ auth = tweepy.OAuthHandler(settings.CONSUMER_KEY, settings.CONSUMER_SECRET)
+ auth.set_access_token(settings.ACCESS_KEY, settings.ACCESS_SECRET)
+ self.api = tweepy.API(auth)
+ tweet = args[0]
+ self.post_tweet(tweet)
+
+ def post_tweet(self, tweet):
+ self.api.update_status(tweet)
+
+
+
+if __name__ == '__main__':
+ parser = OptionParser("usage: %prog [options] [tweet]") # no args this time
+ parser.add_option("-d", "--debug", dest="debug", action="store_true", default=False, help="set debug mode = True")
+ (options, args) = parser.parse_args()
+
+ l = writeTweet(options, args)

0 comments on commit 5ba92aa

Please sign in to comment.