Вопрос

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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top