简体   繁体   English

Tweepy-Twitter API 1.1

[英]Tweepy - Twitter API 1.1

I wrote a program back in API v 1.0 that crawls up tweets using urls, which worked perfectly. 我在API v 1.0中编写了一个程序,该程序使用url爬网推文,效果很好。 Its core part goes like this: 其核心部分如下所示:

import tweepy
auth1 = tweepy.auth.OAuthHandler('something','something')
auth1.set_access_token('something','something')
api=tweepy.API(auth1)

url = "http://api.twitter.com/1/statuses/show.json?id=" + tid
tweet = urllib2.urlopen(url).read()

After 1.1 got released, I've changed the url from 1 to 1.1 and tried getting new OAuth, but it gives me Bad Authentication, code: 215 error. 在发布1.1之后,我已将网址从1更改为1.1,并尝试获取新的OAuth,但是它给了我错误的身份验证,代码:215错误。

This may have been asked before, but I cannot find relevant information. 以前可能已经问过这个问题,但是我找不到相关信息。 What exactly do I need to change from the code above? 我到底需要从上面的代码中更改什么? Please help me out and I will greatly appreciate your help. 请帮助我,非常感谢您的帮助。

Yep, I found, it is statuses/show endpoint you're trying to access. 是的,我发现这是您要访问的statuses/show端点。

You don't need to hardcode a link and authentication, it is all already done in tweepy. 您无需对链接和身份验证进行硬编码,所有这些都已经在tweepy中完成了。 Simply make sure to use its latest version (with 1.1 bindings), and you'll get access to this endpoint with get_status method: 只需确保使用其最新版本(带有1.1绑定),即可使用get_status方法访问此端点:

api = tweepy.api(auth)
tweet = api.get_status(id=tweet_id)

Note that this tweet will be a tweepy tweet model object, and you can access it's fields as 请注意,此tweet将是tweepy tweet模型对象,您可以按以下方式访问其字段:

ir2id = tweet.in_reply_to_status_id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM