twitter_oauth 0.3.6 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/twitter_oauth.rb CHANGED
@@ -5,4 +5,5 @@ require 'mime/types'
5
5
  require 'twitter_oauth/client'
6
6
 
7
7
  module TwitterOAuth
8
+ VERSION = '0.4.0'
8
9
  end
@@ -13,6 +13,7 @@ require 'twitter_oauth/trends'
13
13
  require 'twitter_oauth/lists'
14
14
  require 'twitter_oauth/saved_searches'
15
15
  require 'twitter_oauth/spam'
16
+ require 'twitter_oauth/geo'
16
17
 
17
18
  module TwitterOAuth
18
19
  class Client
@@ -53,11 +54,12 @@ module TwitterOAuth
53
54
  end
54
55
 
55
56
  private
57
+
56
58
  def consumer
57
59
  @consumer ||= OAuth::Consumer.new(
58
60
  @consumer_key,
59
61
  @consumer_secret,
60
- { :site=>"http://twitter.com" }
62
+ { :site => "http://api.twitter.com" }
61
63
  )
62
64
  end
63
65
 
@@ -65,18 +67,21 @@ module TwitterOAuth
65
67
  @access_token ||= OAuth::AccessToken.new(consumer, @token, @secret)
66
68
  end
67
69
 
68
- def get(url)
69
- oauth_response = access_token.get(url)
70
+ def get(path, headers={})
71
+ headers.merge!("User-Agent" => "twitter_oauth gem v#{TwitterOAuth::VERSION}")
72
+ oauth_response = access_token.get("/1#{path}", headers)
70
73
  JSON.parse(oauth_response.body)
71
74
  end
72
75
 
73
- def post(url, body = '', headers = {})
74
- oauth_response = access_token.post(url, body, headers)
76
+ def post(path, body='', headers={})
77
+ headers.merge!("User-Agent" => "twitter_oauth gem v#{TwitterOAuth::VERSION}")
78
+ oauth_response = access_token.post("/1#{path}", body, headers)
75
79
  JSON.parse(oauth_response.body)
76
80
  end
77
81
 
78
- def delete(url)
79
- oauth_response = access_token.delete(url)
82
+ def delete(path, headers={})
83
+ headers.merge!("User-Agent" => "twitter_oauth gem v#{TwitterOAuth::VERSION}")
84
+ oauth_response = access_token.delete("/1#{path}", headers)
80
85
  JSON.parse(oauth_response.body)
81
86
  end
82
87
  end
@@ -0,0 +1,27 @@
1
+ module TwitterOAuth
2
+ class Client
3
+
4
+ # Search for places (cities and neighborhoods) that can be attached to a statuses/update.
5
+ # Given a latitude and a longitude, return a list of all the valid places that can be used as a place_id when updating a status
6
+ def reverse_geocode(lat, lng, options={})
7
+ options[:lat] = lat; options[:lng] = lng
8
+ args = options.map{|k,v| "#{k}=#{v}"}.join('&')
9
+ get "/geo/reverse_geocode.json?#{args}"
10
+ end
11
+
12
+ # Search for places (cities and neighborhoods) that can be attached to a statuses/update.
13
+ # Given a latitude and a longitude pair, or an IP address, return a list of all the valid cities
14
+ # and neighborhoods that can be used as a place_id when updating a status.
15
+ def geo_search(options={})
16
+ options[:query] = URI.escape(options[:query]) if options[:query]
17
+ args = options.map{|k,v| "#{k}=#{v}"}.join('&')
18
+ get "/geo/search.json?#{args}"
19
+ end
20
+
21
+ # Find out more details of a place that was returned from the geo/reverse_geocode method.
22
+ def geo(id)
23
+ get "/geo/id/#{id}.json"
24
+ end
25
+
26
+ end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twitter_oauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Taylor
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-05-06 00:00:00 +01:00
12
+ date: 2010-06-15 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -31,9 +31,6 @@ dependencies:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.1.9
34
- - - <=
35
- - !ruby/object:Gem::Version
36
- version: 1.2.4
37
34
  version:
38
35
  - !ruby/object:Gem::Dependency
39
36
  name: mime-types
@@ -65,7 +62,7 @@ dependencies:
65
62
  - !ruby/object:Gem::Version
66
63
  version: "0"
67
64
  version:
68
- description: twitter_oauth is a Ruby library for talking to twitter using the new oauth method.
65
+ description: twitter_oauth is a Ruby client for the Twitter API using OAuth.
69
66
  email: moomerman@gmail.com
70
67
  executables: []
71
68
 
@@ -83,6 +80,7 @@ files:
83
80
  - lib/twitter_oauth/direct_messages.rb
84
81
  - lib/twitter_oauth/favorites.rb
85
82
  - lib/twitter_oauth/friendships.rb
83
+ - lib/twitter_oauth/geo.rb
86
84
  - lib/twitter_oauth/lists.rb
87
85
  - lib/twitter_oauth/notifications.rb
88
86
  - lib/twitter_oauth/saved_searches.rb
@@ -121,6 +119,6 @@ rubyforge_project: twitter_oauth
121
119
  rubygems_version: 1.3.5
122
120
  signing_key:
123
121
  specification_version: 2
124
- summary: twitter_oauth is a Ruby library for talking to twitter using the new oauth method.
122
+ summary: twitter_oauth is a Ruby client for the Twitter API using OAuth.
125
123
  test_files: []
126
124