使用Twitter API v1.1

时间:2013-07-11 17:10:36

标签: python twitter tweepy

我通过命令python py/twi.py通过终端启动了此代码,但没有显示任何反应:

import oauth, tweepy
from time import sleep    

message = "hello"

def init():
    global api
    #confident information
    consumer_key = "***"
    consumer_secret = "***"
    callback_url = "https://twitter.com/Problem196"
    access_key="***"
    access_secret="***"
    auth = tweepy.OAuthHandler(consumer_key, consumer_secret, callback_url)
    auth.set_access_token(access_key, access_secret)
    api=tweepy.API(auth)

init()
api.update_status(message)

但它应该在页面https://twitter.com/problem196上发布推文“你好”。 我已经更新了tweepy,没关系。为什么不发布?我不知道。请帮忙。 UPD:我把代码print api.last_response.msg终端后给我看了一些错误:

artem@artem-VirtualBox:~$ python py/twi.py
Traceback (most recent call last):
  File "py/twi.py", line 20, in <module>
    api.update_status(message)
  File "/usr/local/lib/python2.7/dist-packages/tweepy-2.1-py2.7.egg/tweepy/binder.py", line 197, in _call
    return method.execute()
  File "/usr/local/lib/python2.7/dist-packages/tweepy-2.1-py2.7.egg/tweepy/binder.py", line 154, in execute
    raise TweepError('Failed to send request: %s' % e)
tweepy.error.TweepError: Failed to send request: [Errno -2] Name or service not known
artem@artem-VirtualBox:~$ python py/twi.py
Traceback (most recent call last):
  File "py/twi.py", line 20, in <module>
    api.update_status(message)
  File "/usr/local/lib/python2.7/dist-packages/tweepy-2.1-py2.7.egg/tweepy/binder.py", line 197, in _call
    return method.execute()
      File "/usr/local/lib/python2.7/dist-packages/tweepy-2.1-py2.7.egg/tweepy/binder.py", line 173, in execute
        raise TweepError(error_msg, resp)
    tweepy.error.TweepError: [{'message': 'Status is a duplicate', 'code': 187}]

0 个答案:

没有答案