Why does Twitter API return the error 'If you need access to this endpoint, you may need a different access level?'

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

Why does Twitter API return the error 'If you need access to this endpoint, you may need a different access level?'

问题

我正在尝试使用Python使用此函数

def create_thread(message_text, media_ids=None):
tweets = [message_text[i:i + 280] for i in range(0, len(message_text), 280)]
if media_ids:
response = client_v1.update_status(status=tweets[0], media_ids=media_ids)
else:
response = client_v2.create_tweet(text=tweets[0])
for tweet in tweets[1:]:
response = client_v2.create_tweet(text=tweet, reply_settings={'reply': {'id': response.id}})
return response


我在Twitter上拥有提升的访问权限,并且我支付了基本计划,该计划包括我正在尝试在Twitter API V2和V1.1中使用的访问权限,但当我尝试使用此函数时,它返回错误:

response = client_v1.update_status(status=tweets[0], media_ids=media_ids)
tweepy.errors.Forbidden: 403 Forbidden
453 - 您目前只能访问Twitter API v2端点和有限的v1.1端点。如果您需要访问此端点,您可能需要不同的访问级别。您可以在此处了解更多信息:https://developer.twitter.com/en/docs/twitter-api/getting-started/about-twitter-api#v2-access-leve

[基本计划的权益表](https://i.stack.imgur.com/WvRcr.png)

该函数发布带有图像和标题的帖子
英文:

I'm trying to use this function with Python

def create_thread(message_text, media_ids=None):
    tweets = [message_text[i:i + 280] for i in range(0, len(message_text), 280)]
    if media_ids:
        response = client_v1.update_status(status=tweets[0], media_ids=media_ids)
    else:
        response = client_v2.create_tweet(text=tweets[0])
    for tweet in tweets[1:]:
        response = client_v2.create_tweet(text=tweet, reply_settings={'reply': {'id': response.id}})
    return response

I Have Elevated Access in Twitter and I pay for the Basic plan, which includes the access that I am trying to use in Twitter API V2 and V1.1, but when I try to use this function, it returns the error:

response = client_v1.update_status(status=tweets[0], media_ids=media_ids)
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

Table of benefits of basic plan

The function tweets a post with an image and a caption

答案1

得分: 2

api v1.1中的UPDATE_STATUS已被弃用,他们没有更新文档和免费/基本/高级计划的收益表。

解决方案:将update_status函数更改为create tweet

之前:

response = client_v1.update_status(status=tweets[0], media_ids=media_ids)

正确方式:

response = client_v2.create_tweet(text=tweets[0], media_ids=media_ids)

文档中表示create tweet不支持media_ids,但实际上是支持的。此外,我一直尝试使用update_status,并将文本发送为Status=tweets[0],但必须更改为text=tweets[0]

英文:

UPDATE_STATUS in api v1.1 is deprecated and they didnt updated the documentation and the table of benefits for Free/ basic / premium plan.

The solution: Change update_status function to create tweet

Before:

response = client_v1.update_status(status=tweets[0], media_ids=media_ids)

Correct:

response = client_v2.create_tweet(text=tweets[0], media_ids=media_ids)

the documentation says that create tweet doesn't work with media_ids, but it worked. Also, I have been trying update_status with the text being sent as Status=tweets[0], but must be exchanged to text=tweets[0]

huangapple
  • 本文由 发表于 2023年5月29日 00:02:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76352378.html
匿名

发表评论

匿名网友

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

确定