Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
A sequence of twitterapi.Status instances, one for each message
'''
if user:
url = 'http://twitter.com/statuses/friends_timeline/%s.json' % user
elif not user and not self._username:
raise TwitterError("User must be specified if API is not authenticated.")
else:
url = 'http://twitter.com/statuses/friends_timeline.json'
parameters = {}
if since:
parameters['since'] = since
if since_id:
parameters['since_id'] = since_id
json = self._FetchUrl(url, parameters=parameters)
data = simplejson.loads(json)
return [Status.NewFromJsonDict(x) for x in data]
@staticmethod
def NewFromJsonDict(data):
'''Create a new instance based on a JSON dict.
Args:
data: A JSON dict, as converted from the JSON in the twitter API
Returns:
A twitterapi.Status instance
'''
if 'user' in data:
user = User.NewFromJsonDict(data['user'])
else:
user = None
return Status(created_at=data.get('created_at', None),
favorited=data.get('favorited', None),
id=data.get('id', None),
text=data.get('text', None),
user=user)