如何使用Twitter API v2检索超过280个字符的推文?

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

How do I use Twitter API v2 to retrieve Tweets longer than 280 characters?

问题

Twitter最近允许已验证用户发推文的字符数超过280,最多可以达到4000个字符。当我使用API检索其中一条较长的推文时,我无法接收到完整的文本 - 它在大约280个字符左右被截断。我在Twitter API文档中没有看到有关此的说明,也许我错过了。在检索推文时,是否需要请求任何额外的字段/扩展?以下是我当前在Python中使用的字段和扩展:

tweet_fields_list = ["id",
                     "text",
                     "author_id",
                     "created_at",
                     "conversation_id",
                     "in_reply_to_user_id",
                     "referenced_tweets",
                     "attachments",
                     "entities"]

expansions_list = ["referenced_tweets.id", "attachments.media_keys"]

media_fields_list = ["media_key","type","url"]
英文:

Twitter recently allowed verified users to Tweet more than 280 characters, up to 4000. When I use the API to retrieve one of these longer Tweets I don't receive the full text - it's cut off around 280 characters. I don't see any notes about this in the Twitter API documentation, maybe I missed it. Are there any additional fields/expansions I need to request when retrieving a Tweet? Here are the fields and expansions I'm currently using (in Python):

tweet_fields_list = ["id",
                     "text",
                     "author_id",
                     "created_at",
                     "conversation_id",
                     "in_reply_to_user_id",
                     "referenced_tweets",
                     "attachments",
                     "entities"]

expansions_list = ["referenced_tweets.id", "attachments.media_keys"]

media_fields_list = ["media_key","type","url"]

答案1

得分: 1

很抱歉,目前不可能。似乎他们仍然将280字符限制应用到是否为Twitter Blue订阅用户。

如果您超过了280字符限制,API将返回400错误请求

查看链接:https://twitter.com/daily_reviewss/status/1690131882153758720

如何使用Twitter API v2检索超过280个字符的推文?

英文:

Unfortunately it is not possible currently. It appears that they are still applying 280 characters limit whether you are Twitter Blue subs or not.

If you exceed the 280 character limit, the api returns a 400 bad request error.

Take a look: https://twitter.com/daily_reviewss/status/1690131882153758720

如何使用Twitter API v2检索超过280个字符的推文?

答案2

得分: 1

尝试在查询中添加 tweet.fields=note_tweet 以获取关于具有超过280个字符的推文的信息,详见文档

英文:

Try adding tweet.fields=note_tweet to the query to get "Information about Tweets with more than 280 characters." per the docs.

huangapple
  • 本文由 发表于 2023年2月24日 04:29:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75550006.html
匿名

发表评论

匿名网友

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

确定