Cannot use tweepy on the free version of Twitter API?

huangapple go评论69阅读模式
英文:

Cannot use tweepy on the free version of Twitter API?

问题

I was able to successfully authenticate my access keys and everything - however, I can't do pretty much any action without getting an error saying this is not in my access plan. Twitter says I am allowed 1500 tweets per month, but I can't use any of it?

我成功验证了我的访问密钥,但是几乎无法执行任何操作,因为出现错误,说这不在我的访问计划中。Twitter说我每月可以发1500条推文,但我无法使用它?

I created a twitter bot using the many tutorials available online - however, whenever I try to use a method they are using, I get an error saying I don't have access to this endpoint and I may need a higher access plan. I am pasting my code and my error message while removing the keys and secrets:

我使用在线上提供的许多教程创建了一个Twitter机器人 - 但是每当我尝试使用他们使用的方法时,我会收到一个错误,说我无法访问这个端点,可能需要更高级别的访问计划。我正在粘贴我的代码和错误消息,同时删除了密钥和秘密:

英文:

I was able to successfully authenticate my access keys and everything - however, I can't do pretty much any action without getting an error saying this is not in my access plan. Twitter says I am allowed 1500 tweets per month, but I can't use any of it?

I created a twitter bot using the many tutorials available online - however, whenever I try to use a method they are using, I get an error saying I don't have access to this endpoint and I may need a higher access plan. I am pasting my code and my error message while removing the keys and secrets:

import tweepy
key = ""
keySecret = " "
accessToken = " "
accessTokenSecret = " "
auth = tweepy.OAuthHandler(key,keySecret)
auth.set_access_token(accessToken,accessTokenSecret)
api = tweepy.API(auth)
api.verify_credentials()

api.update_status("Test")
/Users/kjj/PycharmProjects/personalTesting/venv/bin/python /Users/kjj/PycharmProjects/personalTesting/imageProcessor.py 
Traceback (most recent call last):
  File "/Users/kjj/PycharmProjects/personalTesting/imageProcessor.py", line 11, in <module>
    api.update_status("Test")
  File "/Users/kjj/PycharmProjects/personalTesting/venv/lib/python3.9/site-packages/tweepy/api.py", line 46, in wrapper
    return method(*args, **kwargs)
  File "/Users/kjj/PycharmProjects/personalTesting/venv/lib/python3.9/site-packages/tweepy/api.py", line 979, in update_status
    return self.request(
  File "/Users/kjj/PycharmProjects/personalTesting/venv/lib/python3.9/site-packages/tweepy/api.py", line 271, in request
    raise Forbidden(resp)
tweepy.errors.Forbidden: 403 Forbidden
453 - You currently have access to Twitter API v2 endpoints and limited v1.1 endpoints only. If you need access to this endpoint, you may need a different access level. You can learn more here: https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve

Process finished with exit code 1

答案1

得分: 1

I might be late in answering but you can use tweepy.Client instead of tweepy.API
so your code when converted to tweepy.Client version will look like this.

import tweepy
key = ""
keySecret = ""
accessToken = ""
accessTokenSecret = ""
bearer_token=None
client = tweepy.Client(bearer_token,key,keySecret,accessToken,accessTokenSecret)
#below line is required but putting it here inplace of api.verify_credentials
client.get_me()
client.create_tweet(text="Test")

And this will work as you would expect it to work.

英文:

I might be late in answering but you can use tweepy.Client instead of tweepy.API
so your code when converted to tweepy.Client version will look like this.

import tweepy
key = ""
keySecret = " "
accessToken = " "
accessTokenSecret = " "
bearer_token=None
client = tweepy.Client(bearer_token,key,keySecret,accessToken,accessTokenSecret)
#below line is required but putting it here inplace of api.verify_credentials 
client.get_me() 
client.create_tweet(text="Test")

And this will work as you would expect it to work.

huangapple
  • 本文由 发表于 2023年5月18日 01:44:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76274859.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定