def fetchFriendsTimelinePage(self, api, count, since_id=None, page=1): url = 'http://twitter.com/statuses/friends_timeline.json' parameters = {} parameters['page'] = page parameters['count'] = count if since_id: parameters['since_id'] = since_id obj = api._FetchUrl(url, parameters=parameters) data = json.loads(obj) #api._CheckForTwitterError(data) #log.debug("Loading %d timeline for '%d' since %s" % (len(data), self.user_id, since_id)) statuses = [twitter.Status.NewFromJsonDict(x) for x in data] for s in statuses: g.cache.set(twapi.status_cache_key(s.id), s) return [s.id for s in statuses]
def fetchSearchResultsSince(self, api, term, count, since_id=None): url = 'http://search.twitter.com/search.json' parameters = {} parameters['q'] = term parameters['rpp'] = count if since_id: parameters['since_id'] = since_id obj = twapi.ip_api._FetchUrl(url, parameters=parameters) data = json.loads(obj) #api._CheckForTwitterError(data) #log.debug("Loading %d search results for '%s' since %s" % (len(data['results']), term, since_id) ) for x in data['results']: s = twitter.Status.NewFromJsonDict(x) s.user = twitter.User( id = x.get('from_user_id'), screen_name = x.get('from_user'), profile_image_url = x.get('profile_image_url')) g.cache.set(twapi.status_cache_key(s.id), s) return [x.get('id') for x in data['results']]