简体   繁体   English

Instagram API 速率限制

[英]Instagram API Rate Limit

I'm currently using the Instagram API to like photos and follow users.我目前正在使用 Instagram API 来喜欢照片和关注用户。 I'm passing in the access token to make the requests, but for some reason I keep getting client request limit reached.我正在传递访问令牌以发出请求,但由于某种原因,我不断达到客户端请求限制。 I'm not sure why since the requests are being sent with an access token saved when users authenticate with my app.我不知道为什么,因为当用户使用我的应用程序进行身份验证时,请求是使用保存的访问令牌发送的。

here's the gem I'm using to connect to the API in my Rails app: https://github.com/Instagram/instagram-ruby-gem这是我用来连接到 Rails 应用程序中的 API 的 gem: https : //github.com/Instagram/instagram-ruby-gem

def self.follow_users(token, tags, user_id)
  tags.each do |hashtag|
    Instagram.tag_recent_media(hashtag.content).data.each do |data|
      Instagram.follow_user(data.user.id, :access_token => token)
    end
  end
end

Are you passing the user's access token?您是否正在传递用户的访问令牌? Or are you passing your own (or your app's) access_token ?或者您是否正在传递您自己(或您的应用程序)的access_token

If you're passing your own, the reason you're seeing the rate limit error is because Instagram limits Follows to 60/h and Likes to 150/h .如果你通过自己的,你看到速率限制错误的原因是因为 Instagram 将Follows限制为 60/h 并将 Likes 限制为 150/h You can check the number remaining by inspecting the return HTTP header, and looking for x-ratelimit-remaining .您可以通过检查返回的 HTTP 标头并查找x-ratelimit-remaining来检查x-ratelimit-remaining

Sample response:示例响应:

{
    "error_type": "APIError",
    "code": 400,
    "error_message": "Client request limit reached",
    "x-ratelimit-limit": "150",
    "x-ratelimit-remaining": "3"
}

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

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