简体   繁体   English

推特错误的速率限制

[英]wrong rate limit in twitter

I am new to twitter API started working on it on PHP using this library . 我是twitter的新手,使用这个库开始在PHP上开发它。

// connecting to it and asking for user look up
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$twitter->host = "https://api.twitter.com/1/";
$userInfo= $twitter->post( 'users/lookup', array('user_id' => "".$id)); // i am talking about this line

here I am calling users/lookup for each id I have (I know I can put multiple ids comma seprated) but I didn't know that before; 在这里我调用用户/查找我拥有的每个id(我知道我可以将多个id逗号分隔)但我以前不知道; any way I noticed I get the rate limit of 150 calls why can't I do more? 无论如何我注意到我得到150个电话的速率限制为什么我不能做更多? it should 350 calls since I am using Oauth, is this correct? 自从我使用Oauth以来它应该有350个电话,这是正确的吗?

What am I doing wrong? 我究竟做错了什么?

Lots of problems in your code. 你的代码中有很多问题。

  1. You are using API version 1.0 . 您正在使用API​​版本1.0 users/lookup is not available in 1.0 . users/lookup1.0不可用 Its introduced in 1.1 . 它在1.1引入。 Use endpoint https://api.twitter.com/1.1/ first. 首先使用端点https://api.twitter.com/1.1/
  2. user/lookup is a GET request not POST . user/lookup是一个GET请求,而不是POST see GET user/lookup . 请参阅GET用户/查找 Use $twitter->get() method. 使用$twitter->get()方法。
  3. Rate limit for GET users/lookup is 180 per 15 minute window. GET users/lookup速率限制为每15分钟窗口180 Thats 720 per hour. 这是每小时720 See REST API V1.1 Limits 请参阅REST API V1.1限制

Your final code should something like this, 你的最终代码应该是这样的,

$twitter->host = "https://api.twitter.com/1.1/";
$userInfo= $twitter->get( 'users/lookup', array('user_id' => "".$id));

@shiplu.mokadd.im users/lookup existed in v 1.0 also. @ shiplu.mokadd.im 用户/查找也存在于v 1.0中。

I'm having the same problem with v1, but it seems to be a common problem recently. 我对v1有同样的问题,但最近似乎是一个常见的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM