twitter_oauth 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +45 -0
- data/lib/twitter_oauth.rb +1 -1
- data/lib/twitter_oauth/status.rb +5 -0
- metadata +2 -2
data/README.textile
CHANGED
@@ -80,3 +80,48 @@ client = TwitterOAuth::Client.new(
|
|
80
80
|
client.authorized?
|
81
81
|
=> true
|
82
82
|
</code></pre>
|
83
|
+
|
84
|
+
h2. Working with a Proxy
|
85
|
+
|
86
|
+
Services such as "Apigee Analytics and API Management":http://apigee.com/ require you to proxy your API requests through their servers. The workflow is as follows.
|
87
|
+
|
88
|
+
First you need to authorize the Twitter user via OAuth directly via the Twitter API (this part cannot be proxied)
|
89
|
+
|
90
|
+
<pre><code>client = TwitterOAuth::Client.new(
|
91
|
+
:consumer_key => 'YOUR_APP_CONSUMER_KEY',
|
92
|
+
:consumer_secret => 'YOURA_APP_CONSUMER_SECRET'
|
93
|
+
)
|
94
|
+
request_token = client.request_token(:oauth_callback => 'YOUR_CALLBACK_URL')
|
95
|
+
|
96
|
+
request_token.authorize_url
|
97
|
+
=> http://twitter.com/oauth/authorize?oauth_token=TOKEN
|
98
|
+
</code></pre>
|
99
|
+
|
100
|
+
The user is sent to Twitter to allow the application to access their account and then you need to obtain the access token for the user
|
101
|
+
|
102
|
+
<pre><code>access_token = client.authorize(
|
103
|
+
request_token.token,
|
104
|
+
request_token.secret,
|
105
|
+
:oauth_verifier => params[:oauth_verifier]
|
106
|
+
)
|
107
|
+
|
108
|
+
client.authorized?
|
109
|
+
=> true
|
110
|
+
</code></pre>
|
111
|
+
|
112
|
+
Now you can make all further API calls through the proxy of your choice:
|
113
|
+
|
114
|
+
<pre><code>access_token = @user.access_token # assuming @user
|
115
|
+
client = TwitterOAuth::Client.new(
|
116
|
+
:proxy => 'http://XXX.YYY.apigee.com',
|
117
|
+
:consumer_key => 'YOUR_CONSUMER_KEY',
|
118
|
+
:consumer_secret => 'YOUR-CONSUMER-SECRET',
|
119
|
+
:token => access_token.token,
|
120
|
+
:secret => access_token.secret
|
121
|
+
)
|
122
|
+
|
123
|
+
client.authorized?
|
124
|
+
=> true
|
125
|
+
|
126
|
+
client.update('Proxy via Apigee is working')
|
127
|
+
</code></pre>
|
data/lib/twitter_oauth.rb
CHANGED
data/lib/twitter_oauth/status.rb
CHANGED
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.4.
|
4
|
+
version: 0.4.3
|
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-
|
12
|
+
date: 2010-08-11 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|