【问题标题】:Rails twitter gem search function not limiting count of tweetsRails twitter gem 搜索功能不限制推文数量
【发布时间】:2015-10-21 01:11:08
【问题描述】:

我正在使用 twitter gem 搜索推文,并且我想将搜索结果限制为每个函数调用 10 条推文。我正在使用以下功能

class SayController < ApplicationController
  def hello
    @tweets = $twitter.search("google", options = {count: 10})
  end
end

但我仍然收到了数千条推文,而且它在几个页面加载中耗尽了我的 api 速率限制

我也试过了

        @tweets = $twitter.search("google", count: 10)

    @tweets = $twitter.search("google", count: => 10, :result_type => "recent")

但它从不考虑计数变量,也不限制获取的推文数量。我按照http://www.rubydoc.info/gems/twitter/Twitter/REST/Search 此处的文档进行操作,但我不明白为什么它不起作用

【问题讨论】:

  • 你用的是什么版本?如果您尝试使用参数rpp 而不是count 会怎样?

标签: ruby-on-rails ruby twitter


【解决方案1】:

试试这个

@tweets = $twitter.search("google",:result_type => "recent").take(10)

【讨论】:

  • 谢谢,这有效,为什么要限制 api 调用?而不是参数?
猜你喜欢
  • 2014-07-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-05
  • 2023-04-09
  • 2011-10-21
  • 2015-12-10
  • 1970-01-01
相关资源
最近更新 更多