Python Tweepy:带有';错误的身份验证数据';错误

Python Tweepy:带有';错误的身份验证数据';错误,python,twitter,tweepy,Python,Twitter,Tweepy,这真的是身份验证问题还是与其他问题有关? 我必须修改什么才能消除错误 #!/usr/bin/env python import tweepy ckey = 'xxx' csecret = 'xxx' atoken = 'xxx' asecret = 'xxx' auth = tweepy.OAuthHandler(ckey, csecret) auth.set_access_token(atoken, asecret) api = tweepy.API(auth) results = t

这真的是身份验证问题还是与其他问题有关? 我必须修改什么才能消除错误

#!/usr/bin/env python
import tweepy

ckey = 'xxx'
csecret = 'xxx'
atoken = 'xxx'
asecret = 'xxx'

auth = tweepy.OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)

api = tweepy.API(auth)

results = tweepy.api.search(geocode='50,50,5mi')

for result in results:
    print result.text
    print result.location if hasattr(result, 'location') else "Undefined location"
这就是我得到的错误

C:\Python27\python.exe C:/untitled/testfile.py
Traceback (most recent call last):
  File "C:/untitled/testfile.py", line 18, in <module>
    results = tweepy.api.search(geocode='50,50,5mi')
  File "build\bdist.win-amd64\egg\tweepy\binder.py", line 197, in _call
  File "build\bdist.win-amd64\egg\tweepy\binder.py", line 173, in execute
tweepy.error.TweepError: [{u'message': u'Bad Authentication data', u'code': 215}]
C:\Python27\python.exe C:/untitled/testfile.py
回溯(最近一次呼叫最后一次):
文件“C:/untitled/testfile.py”,第18行,在
results=tweepy.api.search(geocode='50,50,5mi')
文件“build\bdist.win-amd64\egg\tweepy\binder.py”,第197行,在调用中
文件“build\bdist.win-amd64\egg\tweepy\binder.py”,第173行,在execute中
tweepy.error.TweepError:[{u'消息:u'错误的身份验证数据',u'代码:215}]
你做错了:

应该是-

#!/usr/bin/env python
import tweepy

ckey = 'xxx'
csecret = 'xxx'
atoken = 'xxx'
asecret = 'xxx'

auth = tweepy.OAuthHandler(ckey, csecret)
auth.set_access_token(atoken, asecret)

api = tweepy.API(auth)

# here's where you went wrong (tried and tested), should be
#results = api.search(geocode='50,50,5mi')
# try with the following lat long
results = api.search(geocode='39.833193,-94.862794,5mi') 

for result in results:
    print result.text
    print result.location if hasattr(result, 'location') else "Undefined location"

非常感谢。这有助于消除错误。但是我没有打印出任何结果,是你的坐标做的。谢谢。但是为什么我的坐标不起作用呢?我尝试了其他坐标,得到了和以前一样的结果:没有。我不知道为什么!但你们提供的坐标真的存在吗?是的,它们存在。我在纽约试过(40.7144,-74.0060)。没有结果!