fb_graph 0.0.5 → 0.0.6
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/README.rdoc +18 -3
- data/VERSION +1 -1
- data/fb_graph.gemspec +1 -1
- data/lib/fb_graph/connections/feed.rb +5 -0
- data/lib/fb_graph/node.rb +17 -7
- data/lib/fb_graph.rb +8 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -18,7 +18,9 @@ This is a work in progress.
|
|
18
18
|
Now FbGraph supports all objects listed here: http://developers.facebook.com/docs/reference/api/
|
19
19
|
Almost all connections for each object are also supported. (Private message connections are not supported yet)
|
20
20
|
|
21
|
-
===
|
21
|
+
=== GET
|
22
|
+
|
23
|
+
==== Basic Objects
|
22
24
|
|
23
25
|
user = FbGraph::User.fetch('matake')
|
24
26
|
user.name # => 'Nov Matake'
|
@@ -33,7 +35,7 @@ Almost all connections for each object are also supported. (Private message co
|
|
33
35
|
|
34
36
|
:
|
35
37
|
|
36
|
-
|
38
|
+
==== Connections
|
37
39
|
|
38
40
|
# Public connections
|
39
41
|
user = FbGraph::User.fetch('matake')
|
@@ -57,7 +59,7 @@ Almost all connections for each object are also supported. (Private message co
|
|
57
59
|
me.home
|
58
60
|
:
|
59
61
|
|
60
|
-
|
62
|
+
==== Pagination
|
61
63
|
|
62
64
|
user = FbGraph::User.new('matake', :access_token => ACCESS_TOKEN)
|
63
65
|
likes = user.likes # => Array of FbGraph::Like
|
@@ -66,6 +68,19 @@ Almost all connections for each object are also supported. (Private message co
|
|
66
68
|
user.likes(likes.next) # => Array of FbGraph::Like
|
67
69
|
user.likes(likes.previous) # => Array of FbGraph::Like
|
68
70
|
|
71
|
+
=== POST
|
72
|
+
|
73
|
+
==== Status Update
|
74
|
+
|
75
|
+
me = FbGraph::User.me(ACCESS_TOKEN)
|
76
|
+
me.feed!(
|
77
|
+
:message => 'Updating via FbGraph',
|
78
|
+
:picture => 'https://graph.facebook.com/matake/picture',
|
79
|
+
:link => 'http://github.com/nov/fb_graph',
|
80
|
+
:name => 'FbGraph',
|
81
|
+
:description => 'A Ruby wrapper for Facebook Graph API'
|
82
|
+
)
|
83
|
+
|
69
84
|
== Note on Patches/Pull Requests
|
70
85
|
|
71
86
|
* Fork the project.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/fb_graph.gemspec
CHANGED
data/lib/fb_graph/node.rb
CHANGED
@@ -23,8 +23,17 @@ module FbGraph
|
|
23
23
|
protected
|
24
24
|
|
25
25
|
def get(options = {})
|
26
|
-
_endpoint_ = build_endpoint(options)
|
26
|
+
_endpoint_ = build_endpoint(options.merge!(:method => :get))
|
27
27
|
handle_response RestClient.get(_endpoint_)
|
28
|
+
rescue RestClient::Exception => e
|
29
|
+
raise FbGraph::Exception.new(e.http_code, e.message, e.http_body)
|
30
|
+
end
|
31
|
+
|
32
|
+
def post(options = {})
|
33
|
+
_endpoint_ = build_endpoint(options.merge!(:method => :post))
|
34
|
+
handle_response RestClient.post(_endpoint_, options)
|
35
|
+
rescue RestClient::Exception => e
|
36
|
+
raise FbGraph::Exception.new(e.http_code, e.message, e.http_body)
|
28
37
|
end
|
29
38
|
|
30
39
|
private
|
@@ -36,10 +45,12 @@ module FbGraph
|
|
36
45
|
self.endpoint
|
37
46
|
end
|
38
47
|
options[:access_token] ||= self.access_token
|
39
|
-
|
48
|
+
options.delete_if do |k, v|
|
40
49
|
v.blank?
|
41
50
|
end
|
42
|
-
|
51
|
+
if options.delete(:method) == :get && options.present?
|
52
|
+
_endpoint_ << "?#{options.to_query}"
|
53
|
+
end
|
43
54
|
_endpoint_
|
44
55
|
end
|
45
56
|
|
@@ -48,16 +59,15 @@ module FbGraph
|
|
48
59
|
if _response_[:error]
|
49
60
|
case _response_[:error][:type]
|
50
61
|
when 'OAuthAccessTokenException'
|
51
|
-
raise FbGraph::Unauthorized.new(_response_[:error][:message])
|
62
|
+
raise FbGraph::Unauthorized.new(401, _response_[:error][:message])
|
52
63
|
when 'QueryParseException'
|
53
|
-
raise FbGraph::NotFound.new(_response_[:error][:message])
|
64
|
+
raise FbGraph::NotFound.new(404, _response_[:error][:message])
|
54
65
|
else
|
55
|
-
raise FbGraph::Exception.new("#{_response_[:error][:type]} :: #{_response_[:error][:message]}")
|
66
|
+
raise FbGraph::Exception.new(400, "#{_response_[:error][:type]} :: #{_response_[:error][:message]}")
|
56
67
|
end
|
57
68
|
else
|
58
69
|
_response_
|
59
70
|
end
|
60
71
|
end
|
61
|
-
|
62
72
|
end
|
63
73
|
end
|
data/lib/fb_graph.rb
CHANGED
@@ -6,7 +6,14 @@ require 'restclient'
|
|
6
6
|
module FbGraph
|
7
7
|
ROOT_URL = "https://graph.facebook.com"
|
8
8
|
|
9
|
-
class FbGraph::Exception < StandardError
|
9
|
+
class FbGraph::Exception < StandardError
|
10
|
+
attr_accessor :code, :message, :body
|
11
|
+
def initialize(code, message, body = '')
|
12
|
+
@code = code
|
13
|
+
@message = message
|
14
|
+
@body = body
|
15
|
+
end
|
16
|
+
end
|
10
17
|
class FbGraph::Unauthorized < FbGraph::Exception; end
|
11
18
|
class FbGraph::NotFound < FbGraph::Exception; end
|
12
19
|
|