api.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:tweegraph 作者: PGryllos 项目源码 文件源码
def create_api_instance(tokens):
    """return authenticated tweepy api instance. In order to do that
    you need to provide a dictionary which values are the four tokens
    provided by apps.twitter when registering an app.

    Parameters
    ----------
    tokens : dict{'api_key': <api_key>, 'api_secret': <api_secret>,
                  'access': <access>, 'access_secret': <secret_access>}
    """
    auth = tweepy.OAuthHandler(tokens['api_key'], tokens['api_secret'])
    auth.set_access_token(tokens['access'], tokens['access_secret'])
    if 'proxy' in tokens:
        api = tweepy.API(auth, proxy=tokens['proxy'])
    else:
        api = tweepy.API(auth)
    return api
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号