Implemented Retweet api, and removed the update_window from update_status because twitter's post delay is too long for that to be feasible
This commit is contained in:
parent
a61af65195
commit
140b99d47d
5
README
5
README
|
@ -9,7 +9,7 @@ While I doubt it will be terribly useful for anyone other than me, feel free to
|
|||
|
||||
* pyGTK
|
||||
* dateutil
|
||||
* twitter (the dev version, not 0.6), along with my patch (included here)
|
||||
* twitter (the dev version, not 0.6), along with my patches (included here)
|
||||
|
||||
|
||||
For the twitter module, you can download and install it with:
|
||||
|
@ -17,7 +17,8 @@ For the twitter module, you can download and install it with:
|
|||
hg clone https://python-twitter.googlecode.com/hg/ python-twitter
|
||||
cd python-twitter
|
||||
hg update dev
|
||||
hg patch -u "Patrick Wiggins <jpwigan@gmail.com>" ../mytwitter/python-twitter-GetListStatuses.patch
|
||||
patch -p1 < ../mytwitter/python-twitter-GetListStatuses.patch
|
||||
patch -p1 < ../mytwitter/python-twitter-Retweet.patch
|
||||
python build.py build
|
||||
python build.py install --user
|
||||
|
||||
|
|
|
@ -91,7 +91,6 @@ class MyTwitter():
|
|||
self.update_entry.set_text("")
|
||||
self.api.PostUpdate(text, in_reply_to_status_id=self.reply_id)
|
||||
self.reply_id = None
|
||||
self.update_window()
|
||||
|
||||
|
||||
def update_status_callback(self, widget):
|
||||
|
@ -128,9 +127,8 @@ class MyTwitter():
|
|||
self.update_entry.grab_focus()
|
||||
|
||||
|
||||
# fixme: need to implement the retweet API in python-twitter to continue
|
||||
def on_retweet(self, widget):
|
||||
pass
|
||||
self.api.Retweet(widget.id)
|
||||
|
||||
### end class MyTwitter
|
||||
|
||||
|
|
44
python-twitter-Retweet.patch
Normal file
44
python-twitter-Retweet.patch
Normal file
|
@ -0,0 +1,44 @@
|
|||
diff -r 51ac454d5d89 twitter.py
|
||||
--- a/twitter.py Thu Dec 31 15:06:42 2009 -0500
|
||||
+++ b/twitter.py Fri Apr 09 18:08:08 2010 -0400
|
||||
@@ -391,6 +391,10 @@
|
||||
>>> list = api.GetList('list_slug')
|
||||
>>> list.member_count
|
||||
>>> lists = api.GetUserLists()
|
||||
+
|
||||
+ Retweet API:
|
||||
+
|
||||
+ >>> api.Retweet(id)
|
||||
'''
|
||||
|
||||
DEFAULT_CACHE_TIMEOUT = 60 # cache for 1 minute
|
||||
@@ -690,6 +694,29 @@
|
||||
results.append(self.PostUpdate(lines[-1], **kwargs))
|
||||
return results
|
||||
|
||||
+ def Retweet(self, id):
|
||||
+ '''Retweet the specified status update
|
||||
+
|
||||
+ The twitter.Api instance must be authenticated.
|
||||
+
|
||||
+ Args:
|
||||
+ id: The numerical ID of the status update you want to retweet
|
||||
+
|
||||
+ Returns:
|
||||
+ A Status instance representing the retweet
|
||||
+ '''
|
||||
+ try:
|
||||
+ if id:
|
||||
+ long(id)
|
||||
+ except:
|
||||
+ raise TwitterError("id must be a long integer")
|
||||
+ parameters={'id': id}
|
||||
+ url = 'http://api.twitter.com/1/statuses/retweet/%s.json' % id
|
||||
+ json = self._FetchUrl(url, parameters=parameters)
|
||||
+ data = simplejson.loads(json)
|
||||
+ self._CheckForTwitterError(data)
|
||||
+ return NewStatusFromJsonDict(data)
|
||||
+
|
||||
def GetReplies(self, since=None, since_id=None, page=None):
|
||||
'''Get a sequence of status messages representing the 20 most recent
|
||||
replies (status updates prefixed with @username) to the authenticating
|
Reference in New Issue
Block a user