消息“Twitter REST API v1 不再处于活动状态.请迁移到 API v1.1' [英] Message 'The Twitter REST API v1 is no longer active. Please migrate to API v1.1'

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

问题描述

这是我的 Python 代码,它不再起作用了.我收到此消息:Twitter REST API v1 不再处于活动状态.请迁移到 API v1.1".

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".

Python 代码基本上使用 Python-Twitter 库向 Twitter 询问用户的状态x",然后它采用最后一个状态并搜索术语#driptwit".如果找到,它会将 ASCII 值 1 发送到串行端口(以及Arduino).如果找到 #driptwitstop,它会发送一个 ASCII 值 0.最后,它会每 15 秒循环一次并检查 Twitter 帐户以查找更改.

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.

如您所见,下面是您输入您在最后一步从 Twitter 获得的密钥的位置.

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?

实际代码如下:

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.

推荐答案

您的 Twitter 模块所基于的 Twitter API 已停止使用.您需要参考更新后的 Twitter 包,该包将改用 1.1 API.

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.

就像@Madbreaks 所说:您可以使用 Stack Overflow 问题中提供的一些解决方案编写自己的解决方案身份验证用于新的 Twitter API 1.1.

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.

您必须使用他们的 1.1 编写自己的 API,或者找到另一个已经支持 1.1 的包.错误消息的重要部分是:u'Twitter REST API v1 不再处于活动状态.请迁移到 API v1.1.dev.twitter.com/docs/api/1.1/overview.'

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天全站免登陆