简体   繁体   English

Rails + Instagram gem:有什么方法可以获取特定数量的照片吗?

[英]Rails + Instagram gem: Is there any way to get a specific count of photos?

I am trying to get 100 newest photos, like 我正在尝试获取100张最新照片,例如

client.tag_recent_media("cat", count: 100)

but it always return around 40 photos (sometimes 36, sometimes 38 and sometimes 40). 但它总是返回约40张照片(有时36张,有时38张,有时40张)。 I am working with this gem . 我正在处理这个宝石

Is there any wat to fetch 100 photos or 40 is the limit? 是否可以收集100张照片或40张照片?

Thanks 谢谢

This will do the job: 这将完成工作:

def search_method

  result = []
  next_id=nil
  while result.length < 100
    data = client.tag_recent_media("cat", max_id: next_id) if a.length == 0
    next_id = data.pagination.next_max_id
    result.concat(data)
  end

end

You should try something like this 你应该尝试这样的事情

  client.tag_recent_media(1907035, {count: 60})

Unfortunately I think 60 is the maximum amount of photos. 不幸的是,我认为最多可以容纳60张照片。

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

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