信息'Twitter的REST API V1不再有效。请迁移到API V1.1“ [英] Message 'The Twitter REST API v1 is no longer active. Please migrate to API v1.1'

查看:322
本文介绍了信息'Twitter的REST API V1不再有效。请迁移到API V1.1“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的的Python code不工作了。我得到这个消息:Twitter的REST API V1不再活动请迁移至API v1.1的。

Python的code主要使用Python,Twitter的库来问微博为用户的x的状态,并且它然后开出最后的状态,并搜索了#driptwit一词。
如果找到,它的1 ASCII 值发送到串行端口(并到的 Arduino的)。如果发现#driptwitstop,它发送0最后的ASCII值,它循环并检查Twitter帐户每15秒查找更改。

正如你所看到的,下面是你进入你从Twitter中的最后一步了。键

我应该需要在code更改为解决这个问题?

下面是实际code:

 在这里输入code##导入Libraries``进口叽叽喳喳
进口系列
进口时间##验证自己与Twitter
API = twitter.Api(CONSUMER_KEY ='consumerkeyhere',CONSUMER_SECRET ='consumersecrethere',access_token_key ='快捷键',access_token_secret ='accesssecret')##设置你的串口
SER = serial.Serial('特',19200)##检查串口
高清checkokay():
    ser.flushInput()
    time.sleep(3)
    行= ser.readline()
    time.sleep(3)    如果行=='':
        行= ser.readline()
        打印'这里'    ##欢迎辞
    打印欢迎滴蠢货!
    打印煮咖啡..高清driptwit():
    状态= []
    X = 0    状态= api.GetUserTimeline('X')##抓斗最新状态    checkIt = [s.text对于s地位] ##把数组中的地位    滴= checkIt [0] .split()##分割第一鸣叫进言    ##检查匹配和写入串行如果比赛
    如果滴[0] =='#driptwit':
        打印分享Tweet收,使得咖啡
        ser.write('1')
    ELIF点滴[0] =='#driptwitstop:##如果做突破
        ser.write(0)
        打印'停止,等待指示。
    其他:
        ser.write(0)
        打印等待鸣叫而1:
    driptwit()调用##函数driptwit
    time.sleep(15),##睡眠15秒,以避免速率限制。


解决方案

这是你的Twitter模块是基于关闭的已停产的Twitter的API。你需要指的是将使用1.1​​的API,而不是更新的Twitter的包。

就像@Madbreaks说:你也许可以与一些堆栈溢出问题的验证新的Twitter的API 1.1 的。

您必须使用其1.1编写自己的API或找到支持1.1已经在另一个包。错误信息的重要组成部分是: u'The Twitter的REST API V1不再有效。请迁移到API V1.1。 dev.twitter.com/docs/api/1.1/overview。

This is my Python code that does not work anymore. I get this message: "The Twitter REST API v1 is no longer active. Please migrate to API v1.1".

The Python code basically uses the Python-Twitter library to ask Twitter for the status of user "x", and it then takes the last status and searches for the term "#driptwit". If found, it sends the ASCII value of 1 to the serial port (and to the Arduino). If #driptwitstop is found, it sends an ASCII value of 0. Lastly, it loops and checks the Twitter account every 15 seconds looking for changes.

As you can see, below is where you enter the keys you got from Twitter in the last step.

What should I need to change in the code to fix it?

Here is the actual code:

Enter code here

##Import Libraries``

import twitter
import serial
import time

##Authenticate yourself with Twitter
api = twitter.Api(consumer_key='consumerkeyhere', consumer_secret='consumersecrethere', access_token_key='accesskey', access_token_secret='accesssecret')

##Set to your serial port
ser = serial.Serial('COM3', 19200)

## Check serial port
def checkokay():
    ser.flushInput()
    time.sleep(3)
    line = ser.readline()
    time.sleep(3)

    if line == ' ':
        line = ser.readline()
        print 'here'

    ## Welcome message
    print 'Welcome To Drip Twit!'
    print 'Making Coffee..'

def driptwit():
    status = [ ]
    x = 0

    status = api.GetUserTimeline('X') ##Grab latest statuses

    checkIt = [s.text for s in status] ##Put status in an array

    drip = checkIt[0].split() ##Split first tweet into words

    ## Check for match and write to serial if match
    if drip[0] == '#driptwit':
        print 'Tweet received, making coffee'
        ser.write('1')
    elif drip[0] == '#driptwitstop': ##Break if done
        ser.write('0')
        print 'Stopped, awaiting instructions.'
    else:
        ser.write('0')
        print 'Awaiting tweet'

while 1:
    driptwit() ## Call driptwit function
    time.sleep(15) ## Sleep for 15 seconds to avoid rate limiting.

解决方案

The Twitter API that your Twitter module is based off of has been discontinued. You'll need to refer to an updated Twitter package that'll use the 1.1 API instead.

Like @Madbreaks said: You might be able to write your own with some of the solutions presented in Stack Overflow question Authentication for new Twitter API 1.1.

You'll have to write your own API using their 1.1 or find another package that supports 1.1 already. The important part of the error message is: u'The Twitter REST API v1 is no longer active. Please migrate to API v1.1. dev.twitter.com/docs/api/1.1/overview.'

这篇关于信息'Twitter的REST API V1不再有效。请迁移到API V1.1“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆