Browse Source

Retweets/Reposts are now being retrieved from Twitter and the status are being set properly

master
Julio Biason 15 years ago
parent
commit
f1aa5f50ba
  1. 9
      mitterlib/network/networkbase.py
  2. 14
      mitterlib/network/twitter.py

9
mitterlib/network/networkbase.py

@ -129,6 +129,14 @@ class NetworkData(object):
**parent**
The parent of this message, in case of a reply.
**reposted_by**
Username friend of the current user that reposted that message. Some
networks will return the original user in a separate table (Twitter,
in this case, returns the original message with the original user
in a "retweeted_status" structure.) In this case, the network layer
will must return the original user in *name*, *username* and *avatar*,
while the friend username will be moved to *reposted_by*.
**network**
The network id source of the message. Network classes don't need to
@ -143,6 +151,7 @@ class NetworkData(object):
self.message = ''
self.message_time = None
self.parent = ''
self.reposted_by = ''
self.network = ''

14
mitterlib/network/twitter.py

@ -119,6 +119,14 @@ class TwitterNetworkData(NetworkData):
if 'in_reply_to_status_id' in data and data['in_reply_to_status_id']:
self.parent = int(data['in_reply_to_status_id'])
if 'retweeted_status' in data:
self.reposted_by = self.username
retweet_user = data['retweeted_status']['user']
self.name = retweet_user['name']
self.username = retweet_user['screen_name']
self.avatar = retweet_user['profile_image_url']
# Twitter encodes a lot of HTML entities, which are not good when
# you want to *display* then (e.g., "<" returns to us as "&lt;").
@ -267,12 +275,12 @@ class Connection(NetworkBase):
options.add_option(
group=self.NAMESPACE,
option='server_url',
default='http://twitter.com',
default='http://api.twitter.com/1',
is_cmd_option=False)
options.add_option(
group=self.NAMESPACE,
option='secure_server_url',
default='https://twitter.com',
default='https://api.twitter.com/1',
is_cmd_option=False)
auth_options(self.NAMESPACE, options, self.AUTH)
return
@ -332,7 +340,7 @@ class Connection(NetworkBase):
def messages(self):
"""Return a list of NetworkData objects for the main "timeline"."""
return self._timeline('last_tweet', '/statuses/friends_timeline.json')
return self._timeline('last_tweet', '/statuses/home_timeline.json')
def message(self, message_id):
"""Retrieves the information of one message."""

Loading…
Cancel
Save