开发者

What are query_parameters and how do I pass them to Tweetstream::Client...filter(query_parameters = {})

I am using the Tweetstream gem to retrieve statuses from Twitter. This works:

 Tweetstream::Client.new('user', 'pw').track('alice', 'wonderland') 

However, I know want to limit collecting tweets to both (i) specific users with (ii) specific words. The Tweetstream gem provides this method:

 Tweetstream::Client.new('user', 'pw').filter(query_params = {}, &block)

But I can't figure out how to pass query_parameters = {}. I'm trying it like this:

 Tweetstream::Client.new('user', 'pw').filter(
               {:follow => ('212380730', '23234252'), 
                :track => ('alice', 'wonderland') 
               } ) 

But I get errors related to syntax, e.g.,

syntax error, unexpected tSYMBEG, expecting '}'

Thank you for your help!

The following is from the Tweetstream RDOC: filter(query_params = {}, &block)

Make a call to the statuses/filter method of the Streaming API, you may provide :follow, :track or both as options to follow the tweets of specified users or track keywords. This method is provided separately for cases when it would conserve the number of HTTP connections to combine track and follow.

This is the source of the .filter method:

开发者_JS百科
 def filter(query_params = {}, &block)
   [:follow, :track].each do |param|
   if query_params[param].is_a?(Array)
   query_params[param] = query_params[param].collect{|q| q.to_s}.join(',')
     elsif query_params[param]
       query_params[param] = query_params[param].to_s
     end
   end
   start('statuses/filter', query_params.merge(:method => :post), &block)
 end


i think you mean [] instead of using () as your filter and track, the :filter and :track in query params are supposed to be arrays

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜