rest-graph 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/.gitignore +6 -0
  2. data/CHANGES +44 -0
  3. data/CONTRIBUTORS +1 -0
  4. data/README +221 -191
  5. data/README.md +367 -0
  6. data/Rakefile +28 -43
  7. data/TODO +1 -0
  8. data/doc/ToC.md +10 -0
  9. data/doc/dependency.md +78 -0
  10. data/doc/design.md +206 -0
  11. data/doc/rails.md +12 -0
  12. data/doc/test.md +46 -0
  13. data/doc/tutorial.md +142 -0
  14. data/example/rails2/Gemfile +13 -0
  15. data/example/rails2/app/controllers/application_controller.rb +10 -8
  16. data/example/rails2/app/views/application/helper.html.erb +1 -0
  17. data/example/rails2/config/boot.rb +16 -0
  18. data/example/rails2/config/environment.rb +3 -30
  19. data/example/rails2/config/preinitializer.rb +23 -0
  20. data/example/rails2/test/functional/application_controller_test.rb +72 -32
  21. data/example/rails2/test/test_helper.rb +10 -6
  22. data/example/rails3/Gemfile +13 -0
  23. data/example/rails3/Rakefile +7 -0
  24. data/example/rails3/app/controllers/application_controller.rb +118 -0
  25. data/example/rails3/app/views/application/helper.html.erb +1 -0
  26. data/example/rails3/config.ru +4 -0
  27. data/example/rails3/config/application.rb +23 -0
  28. data/example/rails3/config/environment.rb +5 -0
  29. data/example/rails3/config/environments/development.rb +26 -0
  30. data/example/rails3/config/environments/production.rb +49 -0
  31. data/example/rails3/config/environments/test.rb +30 -0
  32. data/example/rails3/config/initializers/secret_token.rb +7 -0
  33. data/example/rails3/config/initializers/session_store.rb +8 -0
  34. data/example/rails3/config/rest-graph.yaml +11 -0
  35. data/example/rails3/config/routes.rb +5 -0
  36. data/example/rails3/test/functional/application_controller_test.rb +183 -0
  37. data/example/rails3/test/test_helper.rb +18 -0
  38. data/example/rails3/test/unit/rails_util_test.rb +44 -0
  39. data/init.rb +1 -1
  40. data/lib/rest-graph.rb +5 -571
  41. data/lib/rest-graph/auto_load.rb +3 -3
  42. data/lib/rest-graph/autoload.rb +3 -3
  43. data/lib/rest-graph/config_util.rb +43 -0
  44. data/lib/rest-graph/core.rb +608 -0
  45. data/lib/rest-graph/facebook_util.rb +74 -0
  46. data/lib/rest-graph/rails_util.rb +85 -37
  47. data/lib/rest-graph/test_util.rb +18 -2
  48. data/lib/rest-graph/version.rb +2 -2
  49. data/rest-graph.gemspec +42 -47
  50. data/task/gemgem.rb +155 -0
  51. data/test/test_api.rb +16 -0
  52. data/test/test_cache.rb +28 -8
  53. data/test/test_error.rb +9 -0
  54. data/test/test_facebook.rb +36 -0
  55. data/test/test_load_config.rb +16 -14
  56. data/test/test_misc.rb +4 -4
  57. data/test/test_parse.rb +10 -4
  58. metadata +146 -186
  59. data/Gemfile.lock +0 -45
  60. data/README.rdoc +0 -337
  61. data/example/rails2/script/console +0 -3
  62. data/example/rails2/script/server +0 -3
  63. data/lib/rest-graph/load_config.rb +0 -41
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ pkg
2
+ rdoc
3
+ *.rbc
4
+ .bundle
5
+ .yardoc
6
+ Gemfile.lock
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
@@ -6,3 +6,4 @@ Barnabas Debreczeni (keo)
6
6
  Florent Vaucelle (florent)
7
7
  Ethan Czahor (ethanz5)
8
8
  Nicolas Fouché (nfo)
9
+ Mariusz Pruszynski (snicky)
data/README CHANGED
@@ -1,26 +1,36 @@
1
- = rest-graph 1.7.0
2
- by Cardinal Blue ( http://cardinalblue.com )
1
+ # rest-graph
2
+ by Cardinal Blue <http://cardinalblue.com>
3
3
 
4
- == LINKS:
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
- * {github}[http://github.com/cardinalblue/rest-graph]
7
- * {rubygems}[http://rubygems.org/gems/rest-graph]
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
- == DESCRIPTION:
12
+ ## LINKS:
12
13
 
13
- A super simple Facebook Open Graph API client
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
- == FEATURES:
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
- == REQUIREMENTS:
29
+ ## REQUIREMENTS:
22
30
 
23
- * Tested with MRI 1.8.7 and 1.9.2 and Rubinius 1.1.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
- == INSTALL:
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
- gem install rest-graph
56
+ gem 'rest-graph', :git => 'git://github.com/cardinalblue/rest-graph.git
40
57
 
41
- or if you want rails plugin and bleeding edge
58
+ Or as a Rails2 plugin:
42
59
 
43
- script/plugin install git://github.com/cardinalblue/rest-graph.git
60
+ ./script/plugin install git://github.com/cardinalblue/rest-graph.git
44
61
 
45
- == QUICK START:
62
+ ## QUICK START:
46
63
 
47
- require 'rest-graph'
48
- rg = RestGraph.new(:access_token => 'myaccesstokenfromfb')
49
- rg.get('me')
50
- rg.get('me/likes')
51
- rg.get('search', :q => 'taiwan')
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
- === Obtaining an access token
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 Controllers. (Your code contributions
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 Controllers:
75
+ adds the following two methods to your controllers:
59
76
 
60
- rest_graph_setup: Attempts to find an access_token from the environment
61
- and initializes a RestGraph object with it.
62
- Most commonly used inside a filter.
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
- rest_graph: Accesses the RestGraph object by rest_graph_setup.
81
+ rest_graph: Accesses the RestGraph object by rest_graph_setup.
65
82
 
66
- === Example usage:
83
+ ### Example usage:
67
84
 
68
- class MyController
69
- include RestGraph::RailsUtil
70
- before_filter do
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
- def myaction
78
- @medata = rest_graph.get('me')
79
- end
80
- end
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
- === Default setup
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
- * {Example}[http://github.com/cardinalblue/rest-graph/blob/master/test/config/rest-graph.yaml]
107
+ * [Example](test/config/rest-graph.yaml)
88
108
 
89
109
  To enable, just require anywhere:
90
110
 
91
- require 'rest-graph/autoload'
111
+ require 'rest-graph'
92
112
 
93
- If you are using Rails and rest-graph as a gem, you can include this
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
- config.gem 'rest-graph', :lib => 'rest-graph/autoload'
115
+ gem 'rest-graph'
97
116
 
98
- Or if using bundler, by adding this line into your Gemfile:
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
- rg = RestGraph.new(
107
- :access_token => TOKEN , # default nil
108
- :graph_server => 'https://graph.facebook.com/', # this is the default
109
- :old_server => 'https://api.facebook.com/' , # this is the default
110
- :accept => 'text/javascript' , # this is the default
111
- :lang => 'en-us' , # this affect search
112
- :auto_decode => true , # decode by json
113
- # default true
114
- :app_id => '123' , # default nil
115
- :secret => '1829' , # default nil
116
-
117
- :cache => {} ,
118
- # A cache for the same API call. Any object quacks like a hash should
119
- # work, and Rails.cache works, too. (because of a patch in RailsUtil)
120
-
121
- :error_handler => lambda{ |hash| raise ::RestGraph::Error.new(hash) },
122
- # This handler callback is only called if auto_decode is
123
- # set to true, otherwise, it's ignored. And raising exception
124
- # is the default unless you're using RailsUtil and enabled
125
- # auto_authorize. That way, RailsUtil would do redirect instead
126
- # of raising an exception.
127
-
128
- :log_method => method(:puts),
129
- # This way, any log message would be output by puts. If you want to
130
- # change the log format, use log_handler instead. See below:
131
-
132
- :log_handler => lambda{ |event|
133
- Rails.logger.
134
- debug("Spent #{event.duration} requesting #{event.url}")})
135
- # You might not want to touch this if you're using RailsUtil.
136
- # Otherwise, the default behavior is do nothing. (i.e. no logging)
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
- rest_graph_setup(#
142
- # == All the above RestGraph options, plus
143
- #
144
- :canvas => 'mycanvas', # default ''
145
- :iframe => true , # default false
146
- :auto_authorize => true , # default false
147
- :auto_authorize_scope => 'email' , # default ''
148
- :auto_authorize_options => {} , # default {}
149
- # auto_authorize means it will do redirect to oauth
150
- # API automatically if the access_token is invalid or
151
- # missing. So you would like to setup scope if you're
152
- # using it. Note that: setting scope implies setting
153
- # auto_authorize to true, even it's false.
154
-
155
- :ensure_authorized => false , # default false
156
- # This means if the access_token is not there,
157
- # then do auto_authorize.
158
-
159
- :write_session => true , # default false
160
- :write_cookies => false , # default false
161
- :write_handler =>
162
- lambda{ |fbs| @cache[uid] = fbs } , # default nil
163
- :check_handler =>
164
- lambda{ @cache[uid] }) # default nil
165
- # If we're not using Facebook JavaScript SDK,
166
- # then we'll need to find a way to store the fbs,
167
- # which contains access_token and/or user id.
168
- # In a FBML canvas application, it seems session
169
- # doesn't work right, so you'll need cookies or
170
- # your custom handler to store it. In a standalone
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/load_config'
187
- RestGraph::LoadConfig.load_config!('path/to/rest-graph.yaml', 'production')
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/autoload' # under Rails, load config/rest-graph.yaml
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
- == API REFERENCE:
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
- === Facebook Graph API:
249
+ #### fql
212
250
 
213
- ==== get
214
- # GET https://graph.facebook.com/me?access_token=TOKEN
215
- rg.get('me')
251
+ Make an arbitrary [FQL][] query
216
252
 
217
- # GET https://graph.facebook.com/me?metadata=1&access_token=TOKEN
218
- rg.get('me', :metadata => '1')
253
+ [FQL]: http://developers.facebook.com/docs/reference/fql/
219
254
 
220
- ==== post
221
- rg.post('me/feed', :message => 'bread!')
255
+ rg.fql('SELECT name FROM page WHERE page_id="123"')
222
256
 
223
- ==== fql
224
- Make an arbitrary
225
- {FQL}[http://developers.facebook.com/docs/reference/fql/] query
257
+ #### fql_multi
226
258
 
227
- rg.fql('SELECT name FROM page WHERE page_id="123"')
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
- ==== fql_multi
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
- rg.old_rest(
237
- 'stream.publish',
238
- { :message => 'Greetings',
239
- :attachment => {:name => 'Wikipedia',
240
- :href => 'http://wikipedia.org/',
241
- :caption => 'Wikipedia says hi.',
242
- :media => [{:type => 'image',
243
- :src => 'http://wikipedia.org/favicon.ico',
244
- :href => 'http://wikipedia.org/'}]
245
- }.to_json,
246
- :action_links => [{:text => 'Go to Wikipedia',
247
- :href => 'http://wikipedia.org/'}
248
- ].to_json
249
- },
250
- :auto_decode => false) # You'll need to set auto_decode to false for
251
- # this API request if Facebook is not returning
252
- # a proper formatted JSON response. Otherwise,
253
- # this could be omitted.
254
-
255
- # Some Old Rest API requires a special access token with app secret
256
- # inside of it. For those methods, use secret_old_rest instead of the
257
- # usual old_rest with common access token.
258
- rg.secret_old_rest('admin.getAppProperties', :properties => 'app_id')
259
-
260
- === Utility Methods:
261
-
262
- ==== parse_xxxx
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
- rg.parse_cookies!(cookies)
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
- rg.parse_rack_env!(env)
304
+ rg.parse_rack_env!(env)
275
305
 
276
- ==== access_token
306
+ #### access_token
277
307
 
278
- rg.access_token
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
- rg.data
284
- rg.data['uid']
285
- rg.data['expires']
313
+ rg.data
314
+ rg.data['uid']
315
+ rg.data['expires']
286
316
 
287
- ==== Default values
317
+ #### Default values
288
318
 
289
319
  Read from the rest-graph.yaml file.
290
320
 
291
- RestGraph.default_xxxx
321
+ RestGraph.default_???
292
322
 
293
- === Other ways of getting an access token
323
+ ### Other ways of getting an access token
294
324
 
295
- ==== authorize_url
325
+ #### authorize_url
296
326
 
297
327
  Returns the redirect URL for authorizing
298
328
 
299
- # https://graph.facebook.com/oauth/authorize?
300
- # client_id=123&redirect_uri=http%3A%2F%2Fw3.org%2F
301
- rg.authorize_url(:redirect_uri => 'http://w3.org/', :scope => 'email')
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
- ==== authorize!
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
- # https://graph.facebook.com/oauth/access_token?
309
- # code=CODE&client_id=123&client_secret=1829&
310
- # redirect_uri=http%3A%2F%2Fw3.org%2F
311
- rg.authorize!(:redirect_uri => 'http://w3.org/', :code => 'CODE')
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
- ==== exchange_sessions
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
- # https://graph.facebook.com/oauth/exchange_sessions?sessions=SESSION
319
- rg.exchange_sessions(:sessions => params[:fb_sig_session_key])
348
+ # https://graph.facebook.com/oauth/exchange_sessions?sessions=SESSION
349
+ rg.exchange_sessions(:sessions => params[:fb_sig_session_key])
320
350
 
321
- == LICENSE:
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,