Twitter Gem 搜索方法 [英] Twitter Gem Search method

查看:33
本文介绍了Twitter Gem 搜索方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码在这里

require 'twitter'



search = Twitter::Search.new.containing("obama")

它回报我们

 #<Twitter::Search:0xb6881f9c @proxy=nil, @gateway=nil, @format=:json, @search_endpoint="https://search.twitter.com/", @consumer_key=nil, @adapter=:net_http, @endpoint="https://api.twitter.com/1/", @oauth_token_secret=nil, @query={:q=>["obama"], :tude=>[]}, @oauth_token=nil, @consumer_secret=nil, @user_agent="Twitter Ruby Gem 1.6.2", @cache=nil>

我只想搜索包含 obama

我该怎么做

推荐答案

你尝试了吗

Twitter.search('Obama') 

Twitter.search('Obama', options = {}) 

我还注意到您缺少身份验证属性.查看 Twitter API 文档 以确保您拥有所有必需"参数.

Also I noticed you are missing Authentication atributes. Take a look into Twitter API Doc to make sure you have all the 'required' params.

PS:您是要搜索所有包含字符串Obama"的推文还是所有带有#Obama 的推文.两种搜索的搜索结果集和准确度都不同.

PS: Do you want to search all the tweets that contains the string 'Obama' or all tweets with #Obama. The search result-set and the accuracy is different for both the searches.

这篇关于Twitter Gem 搜索方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆