facebook-graph 0.1.1 → 0.1.2
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.
@@ -10,7 +10,9 @@ class FacebookGraph::Client
|
|
10
10
|
uri = "#{config[:base_uri]}/#{element_id}"
|
11
11
|
uri += "#{querystring_separator(uri)}access_token=#{CGI.escape(@access_token)}" if @access_token
|
12
12
|
uri += "#{querystring_separator(uri) + hash_to_querystring(options)}" unless options.nil? || options.empty?
|
13
|
-
FacebookGraph::GraphNode.new(parse_json(uri))
|
13
|
+
node = FacebookGraph::GraphNode.new(parse_json(uri))
|
14
|
+
node.access_token = access_token
|
15
|
+
node
|
14
16
|
end
|
15
17
|
|
16
18
|
def current_user(options={})
|
@@ -1,18 +1,22 @@
|
|
1
1
|
class FacebookGraph::GraphNode
|
2
2
|
include FacebookGraph::Helper
|
3
|
+
|
4
|
+
attr_accessor :access_token
|
3
5
|
|
4
6
|
def initialize(properties={})
|
5
|
-
config = FacebookGraph.configuration
|
6
7
|
@properties = symbolize_keys(properties)
|
7
8
|
end
|
8
9
|
|
9
10
|
def method_missing(mname, *args)
|
10
11
|
prop = @properties[mname]
|
11
12
|
return prop unless prop.nil?
|
12
|
-
|
13
|
-
|
14
|
-
options = args[0]
|
15
|
-
|
13
|
+
config = FacebookGraph.configuration
|
14
|
+
prop = "#{config[:base_uri]}/#{node_id}/#{mname}"
|
15
|
+
options = args[0] || {}
|
16
|
+
if options.kind_of?(Hash)
|
17
|
+
options[:access_token] = access_token
|
18
|
+
prop += "#{querystring_separator(prop) + hash_to_querystring(options)}"
|
19
|
+
end
|
16
20
|
mname == :picture ? prop : FacebookGraph::GraphNode.from_array(parse_json(prop))
|
17
21
|
end
|
18
22
|
|
@@ -15,15 +15,8 @@ module FacebookGraph::Helper
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def parse_json(uri, options={:http_method=>:get})
|
18
|
-
result = JSON.parse(send(options.delete(:http_method),uri))
|
19
|
-
if result && result['error']
|
20
|
-
begin
|
21
|
-
raise FacebookGraph.const_get(result['error']['type']), result['error']['message']
|
22
|
-
rescue NameError
|
23
|
-
FacebookGraph.const_set(result['error']['type'], Class.new(Exception))
|
24
|
-
retry
|
25
|
-
end
|
26
|
-
end
|
18
|
+
result = JSON.parse(send(options.delete(:http_method),uri))
|
19
|
+
raise result['error']['message'] if result && result['error']
|
27
20
|
result
|
28
21
|
end
|
29
22
|
|
@@ -32,7 +25,7 @@ module FacebookGraph::Helper
|
|
32
25
|
end
|
33
26
|
|
34
27
|
def hash_to_querystring(hash)
|
35
|
-
hash.map{|k,v| "#{k}=#{v}"}.join('&')
|
28
|
+
hash.map{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
|
36
29
|
end
|
37
30
|
|
38
31
|
def parse_form_data(uri, options={:http_method=>:get})
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facebook-graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pedro A. Vicentini Fracarolli
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-08 00:00:00 -02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|