当前位置: 首页>>代码示例>>Python>>正文


Python Twitter.api_call方法代码示例

本文整理汇总了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
开发者ID:tongsu,项目名称:twitdao,代码行数:69,代码来源:twitdao.py


注:本文中的twitter.Twitter.api_call方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。