Twitter API での認証に問題があります。Python で oauth2 モジュールを使用して、シングル ユーザー サインインを行っています。
次の関数を使用して、フォロワー ID をリクエストしています。
import oauth2 as oauth
def oauth_req(url, key, secret, http_method="GET", post_body=None, http_headers=None):
consumer = oauth.Consumer(key=key, secret=secret)
token = oauth.Token(key=key, secret=secret)
client = oauth.Client(consumer, token)
resp, content = client.request(
url,
method=http_method,
)
return content
次に、以下の例に従って、ドキュメント呼び出し twitter_auth.py から実行します。
ids = twitter_auth.oauth_req('https://api.twitter.com/1.1/followers/ids.json?cursor=-1&screen_name=marksandspencer', 'CONSUMER_KEY', 'CONSUMER_SECRET')
'{"errors":[{"message":"Invalid or expired token","code":89}]}'を返します。
うまくいかないようです。アプリケーションの詳細は問題なく、有効期限が切れていません。そのため、何らかの形で無効である可能性があると想定しています。
前もって感謝します。