Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added configurable search host (via @JonathonMA)

  • Loading branch information...
commit 76e2b444ca71a524fd710a12531c91e554d6fd2f 1 parent 3b0fa25
@moomerman authored
Showing with 7 additions and 6 deletions.
  1. +1 −0  lib/twitter_oauth/client.rb
  2. +6 −6 lib/twitter_oauth/search.rb
View
1  lib/twitter_oauth/client.rb
@@ -27,6 +27,7 @@ def initialize(options = {})
@debug = options[:debug]
@api_version = options[:api_version] || '1'
@api_host = options[:api_host] || 'api.twitter.com'
+ @search_host = options[:search_host] || 'search.twitter.com'
end
def authorize(token, secret, options = {})
View
12 lib/twitter_oauth/search.rb
@@ -2,7 +2,7 @@
module TwitterOAuth
class Client
-
+
def search(q, options={})
options[:page] ||= 1
options[:rpp] ||= 20
@@ -10,25 +10,25 @@ def search(q, options={})
args = options.map{|k,v| "#{k}=#{v}"}.join('&')
search_get("/search.json?#{args}")
end
-
+
# Returns the current top 10 trending topics on Twitter.
def current_trends
search_get("/trends/current.json")
end
-
+
# Returns the top 20 trending topics for each hour in a given day.
def daily_trends
search_get("/trends/daily.json")
end
-
+
# Returns the top 30 trending topics for each day in a given week.
def weekly_trends
search_get("/trends/weekly.json")
end
-
+
private
def search_get(path)
- response = open('http://search.twitter.com' + path, 'User-Agent' => 'github.com/moomerman/twitter_outh')
+ response = open("http://#{@search_host}" + path, 'User-Agent' => "twitter_oauth gem v#{TwitterOAuth::VERSION}")
JSON.parse(response.read)
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.