简体   繁体   中英

Tweepy - Twitter API 1.1

I wrote a program back in API v 1.0 that crawls up tweets using urls, which worked perfectly. 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.

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.

You don't need to hardcode a link and authentication, it is all already done in 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:

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

ir2id = tweet.in_reply_to_status_id

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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