Twitter Rest API:404 没有用户匹配指定的术语

Twitter Rest API: 404 No user matches for specified terms

Twitter 一次最多允许 100 个用户 ID 查询用户个人资料信息。但是如果其中有一个无效的ID,它returns:

404 (Not Found), No user matches for specified terms

没有指定哪个是错误 ID,并且不会为列表中的其余用户返回任何数据。如果列表中的用户关闭了他们的帐户,就会发生这种情况。

有没有一种方法可以识别无效 ID,而无需再次逐一检查列表(并可能达到速率限制)?

您可以使用 puts 命令在第一个循环中打印用户 ID,您可以查看日志文件或控制台以获取无效的用户 ID。

https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-lookup.html

  • If a requested user is unknown, suspended, or deleted, then that user will not be returned in the results list.
  • If none of your lookup criteria can be satisfied by returning a user object, a HTTP 404 will be thrown.

根据我的理解,这意味着:

  • 如果您请求 10 个 userId,其中 1 个被暂停,则请求仍应 return 9 个结果
  • 如果你请求 2 个 userIds 并且它们都被挂起,请求将 return 那个错误

我做了一个快速测试,它似乎和描述的一样有效。 难不成你请求的所有ID都是无效的?