koala 1.3.0 → 1.4.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/.travis.yml +6 -9
- data/CHANGELOG +15 -1
- data/Gemfile +3 -4
- data/koala.gemspec +1 -2
- data/lib/koala/api/graph_api.rb +57 -53
- data/lib/koala/http_service.rb +2 -2
- data/lib/koala/oauth.rb +63 -36
- data/lib/koala/realtime_updates.rb +2 -2
- data/lib/koala/version.rb +1 -1
- data/readme.md +1 -1
- data/spec/cases/graph_api_batch_spec.rb +19 -19
- data/spec/cases/http_service_spec.rb +7 -0
- data/spec/cases/koala_test_spec.rb +5 -0
- data/spec/cases/oauth_spec.rb +72 -32
- data/spec/cases/realtime_updates_spec.rb +7 -0
- data/spec/fixtures/facebook_data.yml +1 -1
- data/spec/fixtures/mock_facebook_responses.yml +12 -3
- data/spec/support/graph_api_shared_examples.rb +19 -21
- data/spec/support/mock_http_service.rb +1 -1
- metadata +14 -12
data/.travis.yml
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
rvm:
|
|
2
|
-
- 1.8.7
|
|
2
|
+
- 1.8.7
|
|
3
3
|
- 1.9.2
|
|
4
4
|
- 1.9.3
|
|
5
5
|
- ruby-head
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
branches:
|
|
12
|
-
except:
|
|
13
|
-
- rdoc
|
|
6
|
+
- jruby-18mode # JRuby in 1.8 mode
|
|
7
|
+
- jruby-19mode # JRuby in 1.9 mode
|
|
8
|
+
- rbx-18mode
|
|
9
|
+
- rbx-19mode
|
|
10
|
+
- ree
|
data/CHANGELOG
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
v1.4
|
|
2
|
+
New methods:
|
|
3
|
+
-- OAuth#exchange_access_token(_info) allows you to extend access tokens you receive (thanks, etiennebarrie!)
|
|
4
|
+
Updated methods:
|
|
5
|
+
-- HTTPServices#encode_params sorts parameters to aid in URL comparison (thanks, sholden!)
|
|
6
|
+
-- get_connections is now aliased as get_connection (use whichever makes sense to you)
|
|
7
|
+
Internal improvements:
|
|
8
|
+
-- Fixed typos (thanks, brycethornton and jpemberthy!)
|
|
9
|
+
-- RealtimeUpdates will no longer execute challenge block unnecessarily (thanks, iainbeeston!)
|
|
10
|
+
Testing improvements:
|
|
11
|
+
-- Added parallel_tests to development gem file
|
|
12
|
+
-- Fixed failing live tests
|
|
13
|
+
-- Koala now tests against JRuby and Rubinius in 1.9 mode on Travis-CI
|
|
14
|
+
|
|
1
15
|
v1.3
|
|
2
16
|
New methods:
|
|
3
17
|
-- OAuth#url_for_dialog creates URLs for Facebook dialog pages
|
|
@@ -24,7 +38,7 @@ Testing improvements:
|
|
|
24
38
|
-- Expanded/improved test coverage
|
|
25
39
|
-- The test suite no longer users any hard-coded user IDs
|
|
26
40
|
-- KoalaTest.test_user_api allows access to the TestUsers instance
|
|
27
|
-
-- Configured tests to run in random order using RSpec 2.8.0rc1
|
|
41
|
+
-- Configured tests to run in random order using RSpec 2.8.0rc1
|
|
28
42
|
|
|
29
43
|
v1.2.1
|
|
30
44
|
New methods:
|
data/Gemfile
CHANGED
|
@@ -5,11 +5,12 @@ group :development do
|
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
group :development, :test do
|
|
8
|
-
gem "typhoeus"
|
|
8
|
+
gem "typhoeus" unless defined? JRUBY_VERSION
|
|
9
9
|
|
|
10
10
|
# Testing infrastructure
|
|
11
11
|
gem 'guard'
|
|
12
12
|
gem 'guard-rspec'
|
|
13
|
+
gem "parallel_tests"
|
|
13
14
|
|
|
14
15
|
if RUBY_PLATFORM =~ /darwin/
|
|
15
16
|
# OS X integration
|
|
@@ -18,8 +19,6 @@ group :development, :test do
|
|
|
18
19
|
end
|
|
19
20
|
end
|
|
20
21
|
|
|
21
|
-
if defined? JRUBY_VERSION
|
|
22
|
-
gem "jruby-openssl"
|
|
23
|
-
end
|
|
22
|
+
gem "jruby-openssl" if defined? JRUBY_VERSION
|
|
24
23
|
|
|
25
24
|
gemspec
|
data/koala.gemspec
CHANGED
|
@@ -5,13 +5,12 @@ require 'koala/version'
|
|
|
5
5
|
Gem::Specification.new do |s|
|
|
6
6
|
s.name = %q{koala}
|
|
7
7
|
s.version = Koala::VERSION
|
|
8
|
-
s.date = %q{2011-10-04}
|
|
9
8
|
|
|
10
9
|
s.summary = %q{A lightweight, flexible library for Facebook with support for the Graph API, the REST API, realtime updates, and OAuth authentication.}
|
|
11
10
|
s.description = %q{Koala is a lightweight, flexible Ruby SDK for Facebook. It allows read/write access to the social graph via the Graph and REST APIs, as well as support for realtime updates and OAuth and Facebook Connect authentication. Koala is fully tested and supports Net::HTTP and Typhoeus connections out of the box and can accept custom modules for other services.}
|
|
12
11
|
s.homepage = %q{http://github.com/arsduo/koala}
|
|
13
12
|
|
|
14
|
-
s.authors = ["Alex Koppel
|
|
13
|
+
s.authors = ["Alex Koppel"]
|
|
15
14
|
s.email = %q{alex@alexkoppel.com}
|
|
16
15
|
|
|
17
16
|
s.files = `git ls-files`.split("\n")
|
data/lib/koala/api/graph_api.rb
CHANGED
|
@@ -17,7 +17,7 @@ module Koala
|
|
|
17
17
|
# token, this will fetch the profile of the active user and the list
|
|
18
18
|
# of the user's friends:
|
|
19
19
|
#
|
|
20
|
-
# @example
|
|
20
|
+
# @example
|
|
21
21
|
# graph = Koala::Facebook::API.new(access_token)
|
|
22
22
|
# user = graph.get_object("me")
|
|
23
23
|
# friends = graph.get_connections(user["id"], "friends")
|
|
@@ -25,7 +25,7 @@ module Koala
|
|
|
25
25
|
# You can see a list of all of the objects and connections supported
|
|
26
26
|
# by the API at http://developers.facebook.com/docs/reference/api/.
|
|
27
27
|
#
|
|
28
|
-
# You can obtain an access token via OAuth or by using the Facebook JavaScript SDK.
|
|
28
|
+
# You can obtain an access token via OAuth or by using the Facebook JavaScript SDK.
|
|
29
29
|
# If you're using the JavaScript SDK, you can use the
|
|
30
30
|
# {Koala::Facebook::OAuth#get_user_from_cookie} method to get the OAuth access token
|
|
31
31
|
# for the active user from the cookie provided by Facebook.
|
|
@@ -35,12 +35,12 @@ module Koala
|
|
|
35
35
|
# Objects
|
|
36
36
|
|
|
37
37
|
# Get information about a Facebook object.
|
|
38
|
-
#
|
|
38
|
+
#
|
|
39
39
|
# @param id the object ID (string or number)
|
|
40
|
-
# @param args any additional arguments
|
|
40
|
+
# @param args any additional arguments
|
|
41
41
|
# (fields, metadata, etc. -- see {http://developers.facebook.com/docs/reference/api/ Facebook's documentation})
|
|
42
42
|
# @param options (see Koala::Facebook::API#api)
|
|
43
|
-
#
|
|
43
|
+
#
|
|
44
44
|
# @raise [Koala::Facebook::APIError] if the ID is invalid or you don't have access to that object
|
|
45
45
|
#
|
|
46
46
|
# @return a hash of object data
|
|
@@ -50,11 +50,11 @@ module Koala
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
# Get information about multiple Facebook objects in one call.
|
|
53
|
-
#
|
|
53
|
+
#
|
|
54
54
|
# @param ids an array or comma-separated string of object IDs
|
|
55
55
|
# @param args (see #get_object)
|
|
56
56
|
# @param options (see Koala::Facebook::API#api)
|
|
57
|
-
#
|
|
57
|
+
#
|
|
58
58
|
# @raise [Koala::Facebook::APIError] if any ID is invalid or you don't have access to that object
|
|
59
59
|
#
|
|
60
60
|
# @return an array of object data hashes
|
|
@@ -70,14 +70,14 @@ module Koala
|
|
|
70
70
|
#
|
|
71
71
|
# @note put_object is (for historical reasons) the same as put_connections.
|
|
72
72
|
# Please use put_connections; in a future version of Koala (2.0?),
|
|
73
|
-
# put_object will issue a POST directly to an individual object, not to a connection.
|
|
73
|
+
# put_object will issue a POST directly to an individual object, not to a connection.
|
|
74
74
|
def put_object(parent_object, connection_name, args = {}, options = {})
|
|
75
75
|
raise APIError.new({"type" => "KoalaMissingAccessToken", "message" => "Write operations require an access token"}) unless @access_token
|
|
76
76
|
graph_call("#{parent_object}/#{connection_name}", args, "post", options)
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
# Delete an object from the Graph if you have appropriate permissions.
|
|
80
|
-
#
|
|
80
|
+
#
|
|
81
81
|
# @param id (see #get_object)
|
|
82
82
|
# @param options (see #get_object)
|
|
83
83
|
#
|
|
@@ -91,27 +91,28 @@ module Koala
|
|
|
91
91
|
# Fetch information about a given connection (e.g. type of activity -- feed, events, photos, etc.)
|
|
92
92
|
# for a specific user.
|
|
93
93
|
# See {http://developers.facebook.com/docs/api Facebook's documentation} for a complete list of connections.
|
|
94
|
-
#
|
|
95
|
-
# @note to access connections like /user_id/CONNECTION/other_user_id,
|
|
94
|
+
#
|
|
95
|
+
# @note to access connections like /user_id/CONNECTION/other_user_id,
|
|
96
96
|
# simply pass "CONNECTION/other_user_id" as the connection_name
|
|
97
97
|
#
|
|
98
98
|
# @param id (see #get_object)
|
|
99
|
-
# @param connection_name what
|
|
99
|
+
# @param connection_name what
|
|
100
100
|
# @param args any additional arguments
|
|
101
101
|
# @param options (see #get_object)
|
|
102
|
-
#
|
|
102
|
+
#
|
|
103
103
|
# @return [Koala::Facebook::API::GraphCollection] an array of object hashes (in most cases)
|
|
104
|
-
def
|
|
104
|
+
def get_connection(id, connection_name, args = {}, options = {})
|
|
105
105
|
# Fetchs the connections for given object.
|
|
106
106
|
graph_call("#{id}/#{connection_name}", args, "get", options)
|
|
107
107
|
end
|
|
108
|
+
alias_method :get_connections, :get_connection
|
|
108
109
|
|
|
109
110
|
|
|
110
111
|
# Write an object to the Graph for a specific user.
|
|
111
|
-
# See {http://developers.facebook.com/docs/api#publishing Facebook's documentation}
|
|
112
|
+
# See {http://developers.facebook.com/docs/api#publishing Facebook's documentation}
|
|
112
113
|
# for all the supported writeable objects.
|
|
113
114
|
#
|
|
114
|
-
# @note (see #
|
|
115
|
+
# @note (see #get_connection)
|
|
115
116
|
#
|
|
116
117
|
# @example
|
|
117
118
|
# graph.put_object("me", "feed", :message => "Hello, world")
|
|
@@ -123,8 +124,8 @@ module Koala
|
|
|
123
124
|
# extended permissions.
|
|
124
125
|
#
|
|
125
126
|
# @param id (see #get_object)
|
|
126
|
-
# @param connection_name (see #
|
|
127
|
-
# @param args (see #
|
|
127
|
+
# @param connection_name (see #get_connection)
|
|
128
|
+
# @param args (see #get_connection)
|
|
128
129
|
# @param options (see #get_object)
|
|
129
130
|
#
|
|
130
131
|
# @return a hash containing the new object's id
|
|
@@ -136,11 +137,11 @@ module Koala
|
|
|
136
137
|
|
|
137
138
|
# Delete an object's connection (for instance, unliking the object).
|
|
138
139
|
#
|
|
139
|
-
# @note (see #
|
|
140
|
-
#
|
|
140
|
+
# @note (see #get_connection)
|
|
141
|
+
#
|
|
141
142
|
# @param id (see #get_object)
|
|
142
|
-
# @param connection_name (see #
|
|
143
|
-
# @args (see #
|
|
143
|
+
# @param connection_name (see #get_connection)
|
|
144
|
+
# @args (see #get_connection)
|
|
144
145
|
# @param options (see #get_object)
|
|
145
146
|
#
|
|
146
147
|
# @return (see #delete_object)
|
|
@@ -150,10 +151,13 @@ module Koala
|
|
|
150
151
|
graph_call("#{id}/#{connection_name}", args, "delete", options)
|
|
151
152
|
end
|
|
152
153
|
|
|
153
|
-
# Fetches a photo.
|
|
154
|
-
# (Facebook returns the src of the photo as a response header; this method parses that properly,
|
|
154
|
+
# Fetches a photo.
|
|
155
|
+
# (Facebook returns the src of the photo as a response header; this method parses that properly,
|
|
155
156
|
# unlike using get_connections("photo").)
|
|
156
157
|
#
|
|
158
|
+
# @param options options for Facebook (see #get_object).
|
|
159
|
+
# To get a different size photo, pass :type => size (small, normal, large, square).
|
|
160
|
+
#
|
|
157
161
|
# @note to delete photos or videos, use delete_object(id)
|
|
158
162
|
#
|
|
159
163
|
# @return the URL to the image
|
|
@@ -199,7 +203,7 @@ module Koala
|
|
|
199
203
|
put_object(*args)
|
|
200
204
|
end
|
|
201
205
|
|
|
202
|
-
# Write directly to the user's wall.
|
|
206
|
+
# Write directly to the user's wall.
|
|
203
207
|
# Convenience method equivalent to put_object(id, "feed").
|
|
204
208
|
#
|
|
205
209
|
# To get wall posts, use get_connections(user, "feed")
|
|
@@ -220,13 +224,13 @@ module Koala
|
|
|
220
224
|
# "picture" => "http://www.example.com/thumbnail.jpg"
|
|
221
225
|
# })
|
|
222
226
|
#
|
|
223
|
-
# @see #put_connections
|
|
227
|
+
# @see #put_connections
|
|
224
228
|
# @return (see #put_connections)
|
|
225
229
|
def put_wall_post(message, attachment = {}, target_id = "me", options = {})
|
|
226
230
|
self.put_object(target_id, "feed", attachment.merge({:message => message}), options)
|
|
227
231
|
end
|
|
228
232
|
|
|
229
|
-
# Comment on a given object.
|
|
233
|
+
# Comment on a given object.
|
|
230
234
|
# Convenience method equivalent to put_connection(id, "comments").
|
|
231
235
|
#
|
|
232
236
|
# To delete comments, use delete_object(comment_id).
|
|
@@ -242,7 +246,7 @@ module Koala
|
|
|
242
246
|
self.put_object(id, "comments", {:message => message}, options)
|
|
243
247
|
end
|
|
244
248
|
|
|
245
|
-
# Like a given object.
|
|
249
|
+
# Like a given object.
|
|
246
250
|
# Convenience method equivalent to put_connections(id, "likes").
|
|
247
251
|
#
|
|
248
252
|
# To get a list of a user's or object's likes, use get_connections(id, "likes").
|
|
@@ -256,7 +260,7 @@ module Koala
|
|
|
256
260
|
self.put_object(id, "likes", {}, options)
|
|
257
261
|
end
|
|
258
262
|
|
|
259
|
-
# Unlike a given object.
|
|
263
|
+
# Unlike a given object.
|
|
260
264
|
# Convenience method equivalent to delete_connection(id, "likes").
|
|
261
265
|
#
|
|
262
266
|
# @param id (see #get_object)
|
|
@@ -275,7 +279,7 @@ module Koala
|
|
|
275
279
|
# @param search_terms the query to search for
|
|
276
280
|
# @param args additional arguments, such as type, fields, etc.
|
|
277
281
|
# @param options (see #get_object)
|
|
278
|
-
#
|
|
282
|
+
#
|
|
279
283
|
# @return [Koala::Facebook::API::GraphCollection] an array of search results
|
|
280
284
|
def search(search_terms, args = {}, options = {})
|
|
281
285
|
args.merge!({:q => search_terms}) unless search_terms.nil?
|
|
@@ -286,10 +290,10 @@ module Koala
|
|
|
286
290
|
# In general, we're trying to avoid adding convenience methods to Koala
|
|
287
291
|
# except to support cases where the Facebook API requires non-standard input
|
|
288
292
|
# such as JSON-encoding arguments, posts directly to objects, etc.
|
|
289
|
-
|
|
290
|
-
# Make an FQL query.
|
|
293
|
+
|
|
294
|
+
# Make an FQL query.
|
|
291
295
|
# Convenience method equivalent to get_object("fql", :q => query).
|
|
292
|
-
#
|
|
296
|
+
#
|
|
293
297
|
# @param query the FQL query to perform
|
|
294
298
|
# @param args (see #get_object)
|
|
295
299
|
# @param options (see #get_object)
|
|
@@ -298,15 +302,15 @@ module Koala
|
|
|
298
302
|
end
|
|
299
303
|
|
|
300
304
|
# Make an FQL multiquery.
|
|
301
|
-
# This method simplifies the result returned from multiquery into a more logical format.
|
|
302
|
-
#
|
|
305
|
+
# This method simplifies the result returned from multiquery into a more logical format.
|
|
306
|
+
#
|
|
303
307
|
# @param queries a hash of query names => FQL queries
|
|
304
308
|
# @param args (see #get_object)
|
|
305
309
|
# @param options (see #get_object)
|
|
306
310
|
#
|
|
307
311
|
# @example
|
|
308
312
|
# @api.fql_multiquery({
|
|
309
|
-
# "query1" => "select post_id from stream where source_id = me()",
|
|
313
|
+
# "query1" => "select post_id from stream where source_id = me()",
|
|
310
314
|
# "query2" => "select fromid from comment where post_id in (select post_id from #query1)"
|
|
311
315
|
# })
|
|
312
316
|
# # returns {"query1" => [obj1, obj2, ...], "query2" => [obj3, ...]}
|
|
@@ -319,15 +323,15 @@ module Koala
|
|
|
319
323
|
results.inject({}) {|outcome, data| outcome[data["name"]] = data["fql_result_set"]; outcome}
|
|
320
324
|
end
|
|
321
325
|
end
|
|
322
|
-
|
|
326
|
+
|
|
323
327
|
# Get a page's access token, allowing you to act as the page.
|
|
324
328
|
# Convenience method for @api.get_object(page_id, :fields => "access_token").
|
|
325
329
|
#
|
|
326
330
|
# @param id the page ID
|
|
327
331
|
# @param args (see #get_object)
|
|
328
|
-
# @param options (see #get_object)
|
|
332
|
+
# @param options (see #get_object)
|
|
329
333
|
#
|
|
330
|
-
# @return the page's access token (discarding expiration and any other information)
|
|
334
|
+
# @return the page's access token (discarding expiration and any other information)
|
|
331
335
|
def get_page_access_token(id, args = {}, options = {})
|
|
332
336
|
result = get_object(id, args.merge(:fields => "access_token"), options) do
|
|
333
337
|
result ? result["access_token"] : nil
|
|
@@ -340,14 +344,14 @@ module Koala
|
|
|
340
344
|
# @param urls the URLs for which you want comments
|
|
341
345
|
# @param args (see #get_object)
|
|
342
346
|
# @param options (see #get_object)
|
|
343
|
-
#
|
|
347
|
+
#
|
|
344
348
|
# @returns a hash of urls => comment arrays
|
|
345
349
|
def get_comments_for_urls(urls = [], args = {}, options = {})
|
|
346
350
|
return [] if urls.empty?
|
|
347
351
|
args.merge!(:ids => urls.respond_to?(:join) ? urls.join(",") : urls)
|
|
348
352
|
get_object("comments", args, options)
|
|
349
353
|
end
|
|
350
|
-
|
|
354
|
+
|
|
351
355
|
def set_app_restrictions(app_id, restrictions_hash, args = {}, options = {})
|
|
352
356
|
graph_call(app_id, args.merge(:restrictions => MultiJson.encode(restrictions_hash)), "post", options)
|
|
353
357
|
end
|
|
@@ -355,9 +359,9 @@ module Koala
|
|
|
355
359
|
# Certain calls such as {#get_connections} return an array of results which you can page through
|
|
356
360
|
# forwards and backwards (to see more feed stories, search results, etc.).
|
|
357
361
|
# Those methods use get_page to request another set of results from Facebook.
|
|
358
|
-
#
|
|
362
|
+
#
|
|
359
363
|
# @note You'll rarely need to use this method unless you're using Sinatra or another non-Rails framework
|
|
360
|
-
# (see {Koala::Facebook::GraphCollection GraphCollection} for more information).
|
|
364
|
+
# (see {Koala::Facebook::GraphCollection GraphCollection} for more information).
|
|
361
365
|
#
|
|
362
366
|
# @param params an array of arguments to graph_call
|
|
363
367
|
# as returned by {Koala::Facebook::GraphCollection.parse_page_url}.
|
|
@@ -367,10 +371,10 @@ module Koala
|
|
|
367
371
|
graph_call(*params)
|
|
368
372
|
end
|
|
369
373
|
|
|
370
|
-
# Execute a set of Graph API calls as a batch.
|
|
371
|
-
# See {https://github.com/arsduo/koala/wiki/Batch-requests batch request documentation}
|
|
374
|
+
# Execute a set of Graph API calls as a batch.
|
|
375
|
+
# See {https://github.com/arsduo/koala/wiki/Batch-requests batch request documentation}
|
|
372
376
|
# for more information and examples.
|
|
373
|
-
#
|
|
377
|
+
#
|
|
374
378
|
# @param http_options HTTP options for the entire request.
|
|
375
379
|
#
|
|
376
380
|
# @yield batch_api [Koala::Facebook::GraphBatchAPI] an API subclass
|
|
@@ -388,7 +392,7 @@ module Koala
|
|
|
388
392
|
# end
|
|
389
393
|
# # => [{"id" => my_id, ...}, {"id"" => koppel_id, ...}]
|
|
390
394
|
#
|
|
391
|
-
# @return an array of results from your batch calls (as if you'd made them individually),
|
|
395
|
+
# @return an array of results from your batch calls (as if you'd made them individually),
|
|
392
396
|
# arranged in the same order they're made.
|
|
393
397
|
def batch(http_options = {}, &block)
|
|
394
398
|
batch_client = GraphBatchAPI.new(access_token, self)
|
|
@@ -399,7 +403,7 @@ module Koala
|
|
|
399
403
|
batch_client
|
|
400
404
|
end
|
|
401
405
|
end
|
|
402
|
-
|
|
406
|
+
|
|
403
407
|
# Make a call directly to the Graph API.
|
|
404
408
|
# (See any of the other methods for example invocations.)
|
|
405
409
|
#
|
|
@@ -408,12 +412,12 @@ module Koala
|
|
|
408
412
|
# @param verb the type of HTTP request to make (get, post, delete, etc.)
|
|
409
413
|
# @options (see #get_object)
|
|
410
414
|
#
|
|
411
|
-
# @yield response when making a batch API call, you can pass in a block
|
|
412
|
-
# that parses the results, allowing for cleaner code.
|
|
415
|
+
# @yield response when making a batch API call, you can pass in a block
|
|
416
|
+
# that parses the results, allowing for cleaner code.
|
|
413
417
|
# The block's return value is returned in the batch results.
|
|
414
418
|
# See the code for {#get_picture} or {#fql_multiquery} for examples.
|
|
415
419
|
# (Not needed in regular calls; you'll probably rarely use this.)
|
|
416
|
-
#
|
|
420
|
+
#
|
|
417
421
|
# @raise [Koala::Facebook::APIError] if Facebook returns an error
|
|
418
422
|
#
|
|
419
423
|
# @return the result from Facebook
|
|
@@ -425,13 +429,13 @@ module Koala
|
|
|
425
429
|
|
|
426
430
|
# turn this into a GraphCollection if it's pageable
|
|
427
431
|
result = GraphCollection.evaluate(result, self)
|
|
428
|
-
|
|
432
|
+
|
|
429
433
|
# now process as appropriate for the given call (get picture header, etc.)
|
|
430
434
|
post_processing ? post_processing.call(result) : result
|
|
431
435
|
end
|
|
432
436
|
|
|
433
437
|
private
|
|
434
|
-
|
|
438
|
+
|
|
435
439
|
def check_response(response)
|
|
436
440
|
# check for Graph API-specific errors
|
|
437
441
|
# this returns an error, which is immediately raised (non-batch)
|
data/lib/koala/http_service.rb
CHANGED
|
@@ -65,7 +65,7 @@ module Koala
|
|
|
65
65
|
|
|
66
66
|
# figure out our options for this request
|
|
67
67
|
request_options = {:params => (verb == "get" ? params : {})}.merge(http_options || {}).merge(process_options(options))
|
|
68
|
-
request_options[:use_ssl] = true if args["access_token"] # require
|
|
68
|
+
request_options[:use_ssl] = true if args["access_token"] # require https if there's a token
|
|
69
69
|
|
|
70
70
|
# set up our Faraday connection
|
|
71
71
|
# we have to manually assign params to the URL or the
|
|
@@ -86,7 +86,7 @@ module Koala
|
|
|
86
86
|
#
|
|
87
87
|
# @return the appropriately-encoded string
|
|
88
88
|
def self.encode_params(param_hash)
|
|
89
|
-
((param_hash || {}).collect do |key_and_value|
|
|
89
|
+
((param_hash || {}).sort_by{|k, v| k.to_s}.collect do |key_and_value|
|
|
90
90
|
key_and_value[1] = MultiJson.encode(key_and_value[1]) unless key_and_value[1].is_a? String
|
|
91
91
|
"#{key_and_value[0].to_s}=#{CGI.escape key_and_value[1]}"
|
|
92
92
|
end).join("&")
|