twitter.py 文件源码

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

项目:naziscore 作者: rbanffy 项目源码 文件源码
def authenticated_get(
        url, customer_key=CUSTOMER_KEY, customer_secret=CUSTOMER_SECRET):
    """Performs an authenticated GET to the given URL, returns the response's
       content.

    See https://dev.twitter.com/oauth/application-only

    """
    token = get_access_token()
    response = urlfetch.fetch(
        url,
        method=urlfetch.GET,
        headers={'Authorization': 'Bearer ' + token})
    if response.status_code == urlfetch.httplib.OK:
        return response.content
    elif response.status_code == urlfetch.httplib.UNAUTHORIZED:
        return response.content  # User is probably suspended
    else:
        message = 'Url ' + url + ' returned ' + response.content
        logging.warning(message)
        raise urlfetch.httplib.HTTPException(message)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号