機械学習の研究の為、Pythonを使ってTwitterのタイムラインを取得したいのです。
Python初心者なのでエラーが自分では解決できません。
解決方法を教えて頂けると幸いです。
pytho
1#!/usr/bin/env python 2# coding: utf-8 3 4import twitter 5import twitkey 6 7CONSUMER_KEY = twitkey.twkey['cons_key'] 8CONSUMER_SECRET = twitkey.twkey['cons_sec'] 9ACCESS_TOKEN_KEY = twitkey.twkey['accto_key'] 10ACCESS_TOKEN_SECRET = twitkey.twkey['accto_sec'] 11 12api = twitter.Api(consumer_key=CONSUMER_KEY, 13 consumer_secret=CONSUMER_SECRET, 14 access_token_key=ACCESS_TOKEN_KEY, 15 access_token_secret=ACCESS_TOKEN_SECRET) 16tweets = api.GetSearch(term=u"#今日") 17for tweet in tweets: 18 print(tweet.text)
import twitkeyで別ファイルの認証キーをインポートしています。
コードはこちらのサイトに掲載されているものを使わせて頂きました。
http://www.jiriki.co.jp/blog/python/python-twitter
エラー内容
C:\Users\User\Anaconda3\python.exe C:/PyCharm/Twitter_Api/twitprint.py
Traceback (most recent call last):
File "C:/PyCharm/Twitter_Api/twitprint.py", line 16, in <module>
tweets = api.GetSearch(term=u"#今日")
File "C:\Users\User\Anaconda3\lib\site-packages\twitter\api.py", line 519, in GetSearch
data = self._ParseAndCheckTwitter(resp.content.decode('utf-8'))
File "C:\Users\User\Anaconda3\lib\site-packages\twitter\api.py", line 4894, in _ParseAndCheckTwitter
self._CheckForTwitterError(data)
File "C:\Users\User\Anaconda3\lib\site-packages\twitter\api.py", line 4914, in _CheckForTwitterError
raise TwitterError(data['errors'])
twitter.error.TwitterError: [{'code': 32, 'message': 'Could not authenticate you.'}]
Process finished with exit code 1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/09/05 02:46