1

我通过终端通过命令启动了这段代码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}]
4

0 回答 0