本文整理汇总了Python中twitter.Twitter.api_call方法的典型用法代码示例。如果您正苦于以下问题:Python Twitter.api_call方法的具体用法?Python Twitter.api_call怎么用?Python Twitter.api_call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitter.Twitter
的用法示例。
在下文中一共展示了Twitter.api_call方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Twitdao
# 需要导入模块: from twitter import Twitter [as 别名]
# 或者: from twitter.Twitter import api_call [as 别名]
#.........这里部分代码省略.........
us=dict(('%s-%s' % (user['id_str'], include_entities), user) for user in users)
us.update(dict(('%s-%s' % (user['screen_name'], include_entities), user) for user in users))
return memcache.set_multi(us, key_prefix="user-", time=USER_CACHE_TIME)
return False
def _cache_user(self, user, **params):
if not 'error' in user:
include_entities = params['include_entities'] if 'include_entities' in params else None
return memcache.set_multi({
('id-%s-%s' % (user['id_str'], include_entities)):user,
('screen_name-%s-%s' % (user['screen_name'], include_entities)):user
}, key_prefix="user-", time=USER_CACHE_TIME)
return False
def _get_cached_user_by_id(self, id, **params):
include_entities = params['include_entities'] if 'include_entities' in params else None
return memcache.get('user-id-%s-%s' % (id, include_entities))
def _get_cached_user_by_screen_name(self, screen_name, **params):
include_entities = params['include_entities'] if 'include_entities' in params else None
return memcache.get('user-screen_name-%s-%s' % (screen_name, include_entities))
#删不全啊。
def _del_cached_user_by_id(self, id, **params):
include_entities = params['include_entities'] if 'include_entities' in params else None
return memcache.delete('user-id-%s-%s' % (id, include_entities))
def _del_cached_user_by_screen_name(self, screen_name, **params):
include_entities = params['include_entities'] if 'include_entities' in params else None
return memcache.delete('user-screen_name-%s-%s' % (screen_name, include_entities))
def public_timeline(self, **params):
#trim_user, include_entities
timeline = self.twitter.api_call('GET','statuses/public_timeline', params)
return timeline
def home_timeline(self, **params):
#since_id, max_id, count, page, trim_user, include_rts, include_entities
timeline = self.twitter.api_call('GET','statuses/home_timeline', params)
self._cache_timeline(timeline, **params)
return timeline
def friends_timeline(self, **params):
#since_id, max_id, count, page, trim_user, include_rts, include_entities
timeline = self.twitter.api_call('GET','statuses/friends_timeline', params)
self._cache_timeline(timeline, **params)
return timeline
def user_timeline(self, **params):
#user_id, screen_name, since_id, max_id, count, page, trim_user, include_rts, include_entities
timeline = self.twitter.api_call('GET','statuses/user_timeline', params)
self._cache_timeline(timeline, **params)
return timeline
def mentions(self, **params):
#since_id, max_id, count, page, trim_user, include_rts, include_entities
timeline = self.twitter.api_call('GET','statuses/mentions', params)
self._cache_timeline(timeline, **params)
return timeline
def retweeted_by_me(self, **params):
#since_id, max_id, count, page, trim_user, include_entities
timeline = self.twitter.api_call('GET','statuses/retweeted_by_me', params)
self._cache_timeline(timeline, **params)
return timeline