在oauth2中找不到Consumer方法

时间:2016-11-20 01:22:17

标签: python twitter oauth2

我正在尝试使用oauth2连接到twitter api。但代码无效,因为它显示错误 AttributeError:'module'对象没有属性'Consumer' oauth2包中有更新吗?如果有,那么另一种方法是什么呢?

def oauth_req(self, url, http_method="GET", post_body=None,
                http_headers=None):`enter code here`
    config = self.parse_config()
    consumer = oauth.Consumer(key=config.get('consumer_key'), secret=config.get('consumer_secret'))
    token = oauth.Token(key=config.get('access_token'), secret=config.get('access_token_secret'))
    client = oauth.Client(consumer, token)

    resp, content = client.request(
        url,
        method=http_method,
        body=post_body or '',
        headers=http_headers
    )
    return content

任何帮助都会非常感激。提前谢谢!

0 个答案:

没有答案
相关问题