rest-graph 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +6 -0
- data/CHANGES +44 -0
- data/CONTRIBUTORS +1 -0
- data/README +221 -191
- data/README.md +367 -0
- data/Rakefile +28 -43
- data/TODO +1 -0
- data/doc/ToC.md +10 -0
- data/doc/dependency.md +78 -0
- data/doc/design.md +206 -0
- data/doc/rails.md +12 -0
- data/doc/test.md +46 -0
- data/doc/tutorial.md +142 -0
- data/example/rails2/Gemfile +13 -0
- data/example/rails2/app/controllers/application_controller.rb +10 -8
- data/example/rails2/app/views/application/helper.html.erb +1 -0
- data/example/rails2/config/boot.rb +16 -0
- data/example/rails2/config/environment.rb +3 -30
- data/example/rails2/config/preinitializer.rb +23 -0
- data/example/rails2/test/functional/application_controller_test.rb +72 -32
- data/example/rails2/test/test_helper.rb +10 -6
- data/example/rails3/Gemfile +13 -0
- data/example/rails3/Rakefile +7 -0
- data/example/rails3/app/controllers/application_controller.rb +118 -0
- data/example/rails3/app/views/application/helper.html.erb +1 -0
- data/example/rails3/config.ru +4 -0
- data/example/rails3/config/application.rb +23 -0
- data/example/rails3/config/environment.rb +5 -0
- data/example/rails3/config/environments/development.rb +26 -0
- data/example/rails3/config/environments/production.rb +49 -0
- data/example/rails3/config/environments/test.rb +30 -0
- data/example/rails3/config/initializers/secret_token.rb +7 -0
- data/example/rails3/config/initializers/session_store.rb +8 -0
- data/example/rails3/config/rest-graph.yaml +11 -0
- data/example/rails3/config/routes.rb +5 -0
- data/example/rails3/test/functional/application_controller_test.rb +183 -0
- data/example/rails3/test/test_helper.rb +18 -0
- data/example/rails3/test/unit/rails_util_test.rb +44 -0
- data/init.rb +1 -1
- data/lib/rest-graph.rb +5 -571
- data/lib/rest-graph/auto_load.rb +3 -3
- data/lib/rest-graph/autoload.rb +3 -3
- data/lib/rest-graph/config_util.rb +43 -0
- data/lib/rest-graph/core.rb +608 -0
- data/lib/rest-graph/facebook_util.rb +74 -0
- data/lib/rest-graph/rails_util.rb +85 -37
- data/lib/rest-graph/test_util.rb +18 -2
- data/lib/rest-graph/version.rb +2 -2
- data/rest-graph.gemspec +42 -47
- data/task/gemgem.rb +155 -0
- data/test/test_api.rb +16 -0
- data/test/test_cache.rb +28 -8
- data/test/test_error.rb +9 -0
- data/test/test_facebook.rb +36 -0
- data/test/test_load_config.rb +16 -14
- data/test/test_misc.rb +4 -4
- data/test/test_parse.rb +10 -4
- metadata +146 -186
- data/Gemfile.lock +0 -45
- data/README.rdoc +0 -337
- data/example/rails2/script/console +0 -3
- data/example/rails2/script/server +0 -3
- data/lib/rest-graph/load_config.rb +0 -41
data/.gitignore
ADDED
data/CHANGES
CHANGED
@@ -1,5 +1,49 @@
|
|
1
1
|
= rest-graph changes history
|
2
2
|
|
3
|
+
== rest-graph 1.8.0 -- 2011-03-08
|
4
|
+
|
5
|
+
* [RestGraph] Now require 'rest-graph/autoload' is deprecated, simply use
|
6
|
+
require 'rest-graph' would require anything you "might" or
|
7
|
+
might not want. Use require 'rest-graph/core' for core
|
8
|
+
functionality instead.
|
9
|
+
|
10
|
+
* [RestGraph] Now RestGraph#get/post has two extra cache options, one is
|
11
|
+
`expires_in', to indicate how long does this result should be
|
12
|
+
cached. Another one is `cache', if passing false, it means
|
13
|
+
the cache should be updated with this request, no matter it's
|
14
|
+
cached or not before.
|
15
|
+
|
16
|
+
* [ConfigUtil] LoadConfig is renamed to ConfigUtil, and autoload is removed.
|
17
|
+
|
18
|
+
* [ConfigUtil] ConfigUtil is extended into RestGraph, so RestGraph.load_config
|
19
|
+
is equivalent to ConfigUtil.load_config.
|
20
|
+
|
21
|
+
* [RailsUtil] Now FBML canvas is no longer supported. Setting iframe in
|
22
|
+
rest-graph.yaml or pass to rest_graph_setup(:iframe => true)
|
23
|
+
would be a no-op. Setting :canvas => 'name' should imply we're
|
24
|
+
using iframe. This make it less trouble to find how to do the
|
25
|
+
redirect correctly.
|
26
|
+
|
27
|
+
* [RailsUtil] Now it should work better with Rails3. Previously, the load
|
28
|
+
order problem would make rest-graph.yaml is not auto-picked.
|
29
|
+
For now we're using Railtie initializer to make it load better.
|
30
|
+
Rails2 should not be affected with this change.
|
31
|
+
|
32
|
+
* [RailsUtil] Now rest-graph related methods are all private or protected,
|
33
|
+
this would avoid them being treated as Rails actions.
|
34
|
+
|
35
|
+
* [RailsUtil] Fixed a bug that calling rest_graph_setup didn't update options
|
36
|
+
for rest_graph. This is fixed by reinitialize rest_graph in
|
37
|
+
rest_graph_setup.
|
38
|
+
|
39
|
+
* [RailsUtil] You can use rest_graph_js_redirect to do full page redirect
|
40
|
+
in canvas iframe.
|
41
|
+
|
42
|
+
* [TestUtil] Fixed stub format for method/fql.multiquery. Facebook has weird
|
43
|
+
and inconsistent format for different API.
|
44
|
+
|
45
|
+
* [FacebookUtil] Added some very Facebook specific utilities.
|
46
|
+
|
3
47
|
== rest-graph 1.7.0 -- 2010-12-30
|
4
48
|
|
5
49
|
* [RestGraph] Renamed rest-graph/auto_load to rest-graph/autoload; auto_load
|
data/CONTRIBUTORS
CHANGED
data/README
CHANGED
@@ -1,26 +1,36 @@
|
|
1
|
-
|
2
|
-
by Cardinal Blue
|
1
|
+
# rest-graph
|
2
|
+
by Cardinal Blue <http://cardinalblue.com>
|
3
3
|
|
4
|
-
|
4
|
+
Tutorial on setting up a sample Facebook application with Rails 3
|
5
|
+
and RestGraph could be found on [samplergthree][]. Instead, if you're
|
6
|
+
an experienced Ruby programmer, you might also want to look at
|
7
|
+
[detailed documents][].
|
5
8
|
|
6
|
-
|
7
|
-
|
8
|
-
* {rdoc}[http://rdoc.info/projects/cardinalblue/rest-graph]
|
9
|
-
* {mailing list}[http://groups.google.com/group/rest-graph/topics]
|
9
|
+
[samplergthree]: https://github.com/cardinalblue/samplergthree
|
10
|
+
[detailed documents]: https://github.com/cardinalblue/rest-graph/blob/master/doc/ToC.md
|
10
11
|
|
11
|
-
|
12
|
+
## LINKS:
|
12
13
|
|
13
|
-
|
14
|
+
* [github](http://github.com/cardinalblue/rest-graph)
|
15
|
+
* [rubygems](http://rubygems.org/gems/rest-graph)
|
16
|
+
* [rdoc](http://rdoc.info/projects/cardinalblue/rest-graph)
|
17
|
+
* [mailing list](http://groups.google.com/group/rest-graph/topics)
|
14
18
|
|
15
|
-
|
19
|
+
## DESCRIPTION:
|
20
|
+
|
21
|
+
A lightweight Facebook Graph API client
|
22
|
+
|
23
|
+
## FEATURES:
|
16
24
|
|
17
25
|
* Simple Graph API call
|
18
26
|
* Simple FQL call
|
19
|
-
* Utility to extract access_token and check sig in cookies
|
27
|
+
* Utility to extract access_token and check sig in cookies/signed_request
|
20
28
|
|
21
|
-
|
29
|
+
## REQUIREMENTS:
|
22
30
|
|
23
|
-
* Tested with MRI 1.8.7 and 1.9.2 and Rubinius 1.
|
31
|
+
* Tested with MRI 1.8.7 and 1.9.2 and Rubinius 1.2.2.
|
32
|
+
Because of development gems can't work well on JRuby,
|
33
|
+
let me know if rest-graph is working on JRuby, thanks!
|
24
34
|
|
25
35
|
* (must) pick one HTTP client:
|
26
36
|
- gem install rest-client
|
@@ -34,144 +44,146 @@ A super simple Facebook Open Graph API client
|
|
34
44
|
* (optional) parse access_token in HTTP_COOKIE
|
35
45
|
- gem install rack
|
36
46
|
|
37
|
-
|
47
|
+
* (optional) to use rest-graph/test_util
|
48
|
+
- gem install rr
|
49
|
+
|
50
|
+
## INSTALLATION:
|
51
|
+
|
52
|
+
gem install rest-graph
|
53
|
+
|
54
|
+
Or if you want development version, put this in Gemfile:
|
38
55
|
|
39
|
-
|
56
|
+
gem 'rest-graph', :git => 'git://github.com/cardinalblue/rest-graph.git
|
40
57
|
|
41
|
-
|
58
|
+
Or as a Rails2 plugin:
|
42
59
|
|
43
|
-
|
60
|
+
./script/plugin install git://github.com/cardinalblue/rest-graph.git
|
44
61
|
|
45
|
-
|
62
|
+
## QUICK START:
|
46
63
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
64
|
+
require 'rest-graph'
|
65
|
+
rg = RestGraph.new(:access_token => 'myaccesstokenfromfb')
|
66
|
+
rg.get('me')
|
67
|
+
rg.get('me/likes')
|
68
|
+
rg.get('search', :q => 'taiwan')
|
52
69
|
|
53
|
-
|
70
|
+
### Obtaining an access token
|
54
71
|
|
55
72
|
If you are using Rails, we recommend that you include a module called
|
56
|
-
RestGraph::RailsUtil into your
|
73
|
+
RestGraph::RailsUtil into your controllers. (Your code contributions
|
57
74
|
for other Ruby frameworks would be appreciated!). RestGraph::RailsUtil
|
58
|
-
adds the following two methods to your
|
75
|
+
adds the following two methods to your controllers:
|
59
76
|
|
60
|
-
|
61
|
-
|
62
|
-
|
77
|
+
rest_graph_setup: Attempts to find an access_token from the environment
|
78
|
+
and initializes a RestGraph object with it.
|
79
|
+
Most commonly used inside a filter.
|
63
80
|
|
64
|
-
|
81
|
+
rest_graph: Accesses the RestGraph object by rest_graph_setup.
|
65
82
|
|
66
|
-
|
83
|
+
### Example usage:
|
67
84
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
rest_graph_setup(:app_id => '123',
|
72
|
-
:canvas => 'mycanvas',
|
73
|
-
:auto_authorize_scope => 'email')
|
74
|
-
# See below for more options
|
75
|
-
end
|
85
|
+
class MyController < ActionController::Base
|
86
|
+
include RestGraph::RailsUtil
|
87
|
+
before_filter :setup
|
76
88
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
89
|
+
def myaction
|
90
|
+
@medata = rest_graph.get('me')
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
def setup
|
95
|
+
rest_graph_setup(:app_id => '123',
|
96
|
+
:canvas => 'mycanvas',
|
97
|
+
:auto_authorize_scope => 'email')
|
98
|
+
# See below for more options
|
99
|
+
end
|
100
|
+
end
|
81
101
|
|
82
|
-
|
102
|
+
### Default setup
|
83
103
|
|
84
104
|
New RestGraph objects can read their default setup configuration from a
|
85
|
-
YAML configuration file.
|
105
|
+
YAML configuration file. Which is the same as passing to rest_graph_setup.
|
86
106
|
|
87
|
-
*
|
107
|
+
* [Example](test/config/rest-graph.yaml)
|
88
108
|
|
89
109
|
To enable, just require anywhere:
|
90
110
|
|
91
|
-
|
111
|
+
require 'rest-graph'
|
92
112
|
|
93
|
-
|
94
|
-
when you specify the gem in your environment file by using:
|
113
|
+
Or if you're using bundler, add this line into Gemfile:
|
95
114
|
|
96
|
-
|
115
|
+
gem 'rest-graph'
|
97
116
|
|
98
|
-
|
99
|
-
|
100
|
-
gem 'rest-graph', :require => 'rest-graph/autoload'
|
101
|
-
|
102
|
-
=== Setup options:
|
117
|
+
## SETUP OPTIONS:
|
103
118
|
|
104
119
|
Here are ALL the available options for new instance of RestGraph.
|
105
120
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
121
|
+
rg = RestGraph.new(
|
122
|
+
:access_token => TOKEN , # default nil
|
123
|
+
:graph_server => 'https://graph.facebook.com/', # this is default
|
124
|
+
:old_server => 'https://api.facebook.com/' , # this is default
|
125
|
+
:accept => 'text/javascript' , # this is default
|
126
|
+
:lang => 'en-us' , # affect search
|
127
|
+
:auto_decode => true , # decode by json
|
128
|
+
# default true
|
129
|
+
:app_id => '123' , # default nil
|
130
|
+
:secret => '1829' , # default nil
|
131
|
+
|
132
|
+
:cache => {} ,
|
133
|
+
# A cache for the same API call. Any object quacks like a hash
|
134
|
+
# should work, and Rails.cache works, too. (because of a patch in
|
135
|
+
# RailsUtil)
|
136
|
+
|
137
|
+
:error_handler => lambda{|hash| raise RestGraph::Error.new(hash)},
|
138
|
+
# This handler callback is only called if auto_decode is
|
139
|
+
# set to true, otherwise, it's ignored. And raising exception
|
140
|
+
# is the default unless you're using RailsUtil and enabled
|
141
|
+
# auto_authorize. That way, RailsUtil would do redirect
|
142
|
+
# instead of raising an exception.
|
143
|
+
|
144
|
+
:log_method => method(:puts),
|
145
|
+
# This way, any log message would be output by puts. If you want to
|
146
|
+
# change the log format, use log_handler instead. See below:
|
147
|
+
|
148
|
+
:log_handler => lambda{ |event|
|
149
|
+
Rails.logger.
|
150
|
+
debug("Spent #{event.duration} requesting #{event.url}")})
|
151
|
+
# You might not want to touch this if you're using RailsUtil.
|
152
|
+
# Otherwise, the default behavior is do nothing. (i.e. no logging)
|
137
153
|
|
138
154
|
And here are ALL the available options for rest_graph_setup. Note that all
|
139
155
|
options for RestGraph instance are also valid options for rest_graph_setup.
|
140
156
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
# site or iframe canvas application, you might want
|
172
|
-
# to just use the Rails (or other framework) session.
|
173
|
-
|
174
|
-
=== Alternate ways to setup RestGraph:
|
157
|
+
rest_graph_setup(#
|
158
|
+
# == All the above RestGraph options, plus
|
159
|
+
#
|
160
|
+
:canvas => 'mycanvas', # default ''
|
161
|
+
:auto_authorize => true , # default false
|
162
|
+
:auto_authorize_scope => 'email' , # default ''
|
163
|
+
:auto_authorize_options => {} , # default {}
|
164
|
+
# auto_authorize means it will do redirect to oauth
|
165
|
+
# API automatically if the access_token is invalid or
|
166
|
+
# missing. So you would like to setup scope if you're
|
167
|
+
# using it. Note that: setting scope implies setting
|
168
|
+
# auto_authorize to true, even it's false.
|
169
|
+
|
170
|
+
:ensure_authorized => false , # default false
|
171
|
+
# This means if the access_token is not there,
|
172
|
+
# then do auto_authorize.
|
173
|
+
|
174
|
+
:write_session => true , # default false
|
175
|
+
:write_cookies => false , # default false
|
176
|
+
:write_handler =>
|
177
|
+
lambda{ |fbs| @cache[uid] = fbs } , # default nil
|
178
|
+
:check_handler =>
|
179
|
+
lambda{ @cache[uid] }) # default nil
|
180
|
+
# If we're not using Facebook JavaScript SDK,
|
181
|
+
# then we'll need to find a way to store the fbs,
|
182
|
+
# which contains access_token and/or user id. In a
|
183
|
+
# standalone site or iframe canvas application, you might
|
184
|
+
# want to just use the Rails (or other framework) session
|
185
|
+
|
186
|
+
### Alternate ways to setup RestGraph:
|
175
187
|
|
176
188
|
1. Set upon RestGraph object creation:
|
177
189
|
|
@@ -183,13 +195,13 @@ options for RestGraph instance are also valid options for rest_graph_setup.
|
|
183
195
|
|
184
196
|
3. Load from a YAML file
|
185
197
|
|
186
|
-
require 'rest-graph/
|
187
|
-
RestGraph
|
198
|
+
require 'rest-graph/config_util'
|
199
|
+
RestGraph.load_config('path/to/rest-graph.yaml', 'production')
|
188
200
|
rg = RestGraph.new
|
189
201
|
|
190
202
|
4. Load config automatically
|
191
203
|
|
192
|
-
require 'rest-graph
|
204
|
+
require 'rest-graph' # under Rails, would load config/rest-graph.yaml
|
193
205
|
rg = RestGraph.new
|
194
206
|
|
195
207
|
5. Override directly
|
@@ -206,119 +218,137 @@ options for RestGraph instance are also valid options for rest_graph_setup.
|
|
206
218
|
RestGraph.send(:extend, MyDefaults)
|
207
219
|
rg = RestGraph.new
|
208
220
|
|
209
|
-
|
221
|
+
## API REFERENCE:
|
222
|
+
|
223
|
+
### Facebook Graph API:
|
224
|
+
|
225
|
+
#### get
|
226
|
+
# GET https://graph.facebook.com/me?access_token=TOKEN
|
227
|
+
rg.get('me')
|
228
|
+
|
229
|
+
# GET https://graph.facebook.com/me?metadata=1&access_token=TOKEN
|
230
|
+
rg.get('me', :metadata => '1')
|
231
|
+
|
232
|
+
# extra options:
|
233
|
+
# auto_decode: Bool # decode with json or not in this method call
|
234
|
+
# # default: auto_decode in rest-graph instance
|
235
|
+
# secret: Bool # use secret_acccess_token or not
|
236
|
+
# # default: false
|
237
|
+
# cache: Bool # use cache or not; if it's false, update cache, too
|
238
|
+
# # default: true
|
239
|
+
# expires_in: Int # control when would the cache be expired
|
240
|
+
# # default: nothing
|
241
|
+
# async: Bool # use eventmachine for http client or not
|
242
|
+
# # default: false, but true in aget family
|
243
|
+
rg.get('me', {:metadata => '1'}, :secret => true, expires_in => 600)
|
244
|
+
|
245
|
+
#### post
|
246
|
+
|
247
|
+
rg.post('me/feed', :message => 'bread!')
|
210
248
|
|
211
|
-
|
249
|
+
#### fql
|
212
250
|
|
213
|
-
|
214
|
-
# GET https://graph.facebook.com/me?access_token=TOKEN
|
215
|
-
rg.get('me')
|
251
|
+
Make an arbitrary [FQL][] query
|
216
252
|
|
217
|
-
|
218
|
-
rg.get('me', :metadata => '1')
|
253
|
+
[FQL]: http://developers.facebook.com/docs/reference/fql/
|
219
254
|
|
220
|
-
|
221
|
-
rg.post('me/feed', :message => 'bread!')
|
255
|
+
rg.fql('SELECT name FROM page WHERE page_id="123"')
|
222
256
|
|
223
|
-
|
224
|
-
Make an arbitrary
|
225
|
-
{FQL}[http://developers.facebook.com/docs/reference/fql/] query
|
257
|
+
#### fql_multi
|
226
258
|
|
227
|
-
|
259
|
+
rg.fql_multi(:q1 => 'SELECT name FROM page WHERE page_id="123"',
|
260
|
+
:q2 => 'SELECT name FROM page WHERE page_id="456"')
|
228
261
|
|
229
|
-
|
230
|
-
rg.fql_multi(:q1 => 'SELECT name FROM page WHERE page_id="123"',
|
231
|
-
:q2 => 'SELECT name FROM page WHERE page_id="456"')
|
262
|
+
#### old_rest
|
232
263
|
|
233
|
-
==== old_rest
|
234
264
|
Call functionality from Facebook's old REST API:
|
235
265
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
266
|
+
rg.old_rest(
|
267
|
+
'stream.publish',
|
268
|
+
{ :message => 'Greetings',
|
269
|
+
:attachment => {:name => 'Wikipedia',
|
270
|
+
:href => 'http://wikipedia.org/',
|
271
|
+
:caption => 'Wikipedia says hi.',
|
272
|
+
:media => [{:type => 'image',
|
273
|
+
:src => 'http://wikipedia.org/logo.png',
|
274
|
+
:href => 'http://wikipedia.org/'}]
|
275
|
+
}.to_json,
|
276
|
+
:action_links => [{:text => 'Go to Wikipedia',
|
277
|
+
:href => 'http://wikipedia.org/'}
|
278
|
+
].to_json
|
279
|
+
},
|
280
|
+
:auto_decode => false) # You'll need to set auto_decode to false for
|
281
|
+
# this API request if Facebook is not returning
|
282
|
+
# a proper formatted JSON response. Otherwise,
|
283
|
+
# this could be omitted.
|
284
|
+
|
285
|
+
# Some Old Rest API requires a special access token with app secret
|
286
|
+
# inside of it. For those methods, use secret_old_rest instead of the
|
287
|
+
# usual old_rest with common access token.
|
288
|
+
rg.secret_old_rest('admin.getAppProperties', :properties => 'app_id')
|
289
|
+
|
290
|
+
### Utility Methods:
|
291
|
+
|
292
|
+
#### parse_???
|
263
293
|
|
264
294
|
All the methods that obtain an access_token will automatically save it.
|
265
295
|
|
266
296
|
If you have the session in the cookies,
|
267
297
|
then RestGraph can parse the cookies:
|
268
298
|
|
269
|
-
|
299
|
+
rg.parse_cookies!(cookies)
|
270
300
|
|
271
301
|
If you're writing a Rack application, you might want to parse
|
272
302
|
the session directly from Rack env:
|
273
303
|
|
274
|
-
|
304
|
+
rg.parse_rack_env!(env)
|
275
305
|
|
276
|
-
|
306
|
+
#### access_token
|
277
307
|
|
278
|
-
|
308
|
+
rg.access_token
|
279
309
|
|
280
310
|
Data associated with the access_token (which might or might not
|
281
311
|
available, depending on how the access_token was obtained).
|
282
312
|
|
283
|
-
|
284
|
-
|
285
|
-
|
313
|
+
rg.data
|
314
|
+
rg.data['uid']
|
315
|
+
rg.data['expires']
|
286
316
|
|
287
|
-
|
317
|
+
#### Default values
|
288
318
|
|
289
319
|
Read from the rest-graph.yaml file.
|
290
320
|
|
291
|
-
|
321
|
+
RestGraph.default_???
|
292
322
|
|
293
|
-
|
323
|
+
### Other ways of getting an access token
|
294
324
|
|
295
|
-
|
325
|
+
#### authorize_url
|
296
326
|
|
297
327
|
Returns the redirect URL for authorizing
|
298
328
|
|
299
|
-
|
300
|
-
|
301
|
-
|
329
|
+
# https://graph.facebook.com/oauth/authorize?
|
330
|
+
# client_id=123&redirect_uri=http%3A%2F%2Fw3.org%2F
|
331
|
+
rg.authorize_url(:redirect_uri => 'http://w3.org/', :scope => 'email')
|
302
332
|
|
303
|
-
|
333
|
+
#### authorize!
|
304
334
|
|
305
335
|
Makes a call to Facebook to convert
|
306
336
|
the authorization "code" into an access token:
|
307
337
|
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
338
|
+
# https://graph.facebook.com/oauth/access_token?
|
339
|
+
# code=CODE&client_id=123&client_secret=1829&
|
340
|
+
# redirect_uri=http%3A%2F%2Fw3.org%2F
|
341
|
+
rg.authorize!(:redirect_uri => 'http://w3.org/', :code => 'CODE')
|
312
342
|
|
313
|
-
|
343
|
+
#### exchange_sessions
|
314
344
|
|
315
345
|
Takes a session key from the old REST API
|
316
346
|
(non-Graph API) and converts to an access token:
|
317
347
|
|
318
|
-
|
319
|
-
|
348
|
+
# https://graph.facebook.com/oauth/exchange_sessions?sessions=SESSION
|
349
|
+
rg.exchange_sessions(:sessions => params[:fb_sig_session_key])
|
320
350
|
|
321
|
-
|
351
|
+
## LICENSE:
|
322
352
|
|
323
353
|
Apache License 2.0
|
324
354
|
|
@@ -328,7 +358,7 @@ Takes a session key from the old REST API
|
|
328
358
|
you may not use this file except in compliance with the License.
|
329
359
|
You may obtain a copy of the License at
|
330
360
|
|
331
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
361
|
+
<http://www.apache.org/licenses/LICENSE-2.0>
|
332
362
|
|
333
363
|
Unless required by applicable law or agreed to in writing, software
|
334
364
|
distributed under the License is distributed on an "AS IS" BASIS,
|