다음은 제 코드입니다. - 모든 인증 매개 변수를 두 번 확인했습니다.Oauth2를 사용하여 tweepy에서 api.update_status 메소드를 사용하는 중 오류가 발생했습니다.
import tweepy
CONSUMER_KEY ='#Omitted - you should not publish your actual key'
CONSUMER_SECRET ='#Omitted - you should not publish your actual secret'
ACCESS_KEY='#Omitted - you should not publish your access key'
ACCESS_SECRET = '#Omitted - you should not publish your access secret'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)
api.update_status('Tweeting from command line')
오류를 follwing을 파이썬 status.py를 실행 한 후 status.py 로 홈 폴더에 파일을 저장 제공 : -
Traceback (most recent call last):
File "status.py", line 14, in <module>
api.update_status('Tweeting from command line')
File "/usr/local/lib/python2.7/dist-packages/tweepy-1.10-py2.7.egg/tweepy/binder.py", line 185, in _call
return method.execute()
File "/usr/local/lib/python2.7/dist-packages/tweepy-1.10-py2.7.egg/tweepy/binder.py", line 168, in execute
raise TweepError(error_msg, resp)
tweepy.error.TweepError: Could not authenticate with OAuth.
, 나는 인증 할 수 있어요
내가 유 말했다 라인을 추가 ... 여기 코드는 지금과 같은 모습입니다 : - tweepy 수입 OAuthHandler에서 수입 tweepy CONSUMER_KEY = '#의' CONSUMER_SECRET = '#' ACCESS_KEY = '#' ACCESS_SECRET = '#' 인증 = tweepy.OAuthHandler (CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token (ACCESS_KEY, ACCESS_SECRET) API = tweepy.API (인증) 인쇄 api.me(). api.update_status 이름 ('Tweeting from command line') – Divyanshu
여기에 오류가 있습니다 : -, 역 추적 (마지막으로 가장 최근에 호출). 파일 "newstatus.py", 라인 (13), 인쇄 api.me에서() 파일의 이름을 "/usr/local/lib/python2.7/dist-packages/ tweepy-1.10-py2.7.egg/tweepy/api.py ", 182 행, 내 안에 return self.get_user (screen_name = self.auth.get_username()) 파일"/ usr/local/lib/python2. 7/dist-packages/tweepy-1.10-py2.7.egg/tweepy/auth.py ", 줄 161, get_username에서 올리기 TweepError ("사용자 이름을 가져올 수 없습니다. oauth 토큰이 없습니다! ") tweepy.error.TweepError : 사용자 이름, 잘못된 oauth 토큰을 가져올 수 없습니다! –
Divyanshu
Tweepy가 oAuth 토큰을 얻는 데 어려움을 겪고있는 것처럼 보입니다. dev.twitter.com 로그인을 확인하고 모든 것이 정확해야합니다. 코드를 복사하여 붙여 넣기 만하면됩니다. 또한 원래의 질문을 수정하기 위해 나중에 확인해보십시오. 이렇게하면 응답 할 때 문자 제한이 없습니다. –