auth = tweepy.OAuthHandler(consumer_token, consumer_secret)
When I run this line of tweepy code i run into two problems. I receive the code "Tweepy has no attribute OAuthHandler" despite that being in the docum开发者_StackOverflow中文版entation I found. One assumes that that would be valid code.
The second problem is that when I registered my app, I did not receive a consumer_ token. I'm not quite sure how to request a consumer token either.
First you have to get both the consumer_token
and the consumer_secret
. When you register the app it gives you a couple of strings you then use for authentication. The consumer_token
is the Consumer Key string twitter provides you with, and then the consumer_secret
is the Consumer Secret twitter provides you with.
Then when you call auth = tweepy.OAuthHandler(consumer_token, consumer_secret)
you have to have set both the consumer_token
and the consumer_secret
to the strings twitter provided you with. Then this should work.
- Make sure you have
import tweepy
before you attempt to call any of its classes. That sounds like the main problem you are having.
- You will need 2 sets of keys, the consumer keys, and the access tokens. Both are available on the https://dev.twitter.com/apps page where you have your registered app. The consumer keys are used by the OAuthHandler(), and the access tokens are used by set_access_token(). Please see this example of using OAuthHandler
精彩评论