fb_graph 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/fb_graph.gemspec +63 -2
- data/lib/fb_graph/album.rb +6 -3
- data/lib/fb_graph/comment.rb +1 -1
- data/lib/fb_graph/connections/attending.rb +1 -5
- data/lib/fb_graph/connections/declined.rb +1 -5
- data/lib/fb_graph/connections/invited.rb +1 -5
- data/lib/fb_graph/connections/maybe.rb +1 -5
- data/lib/fb_graph/connections/members.rb +2 -6
- data/lib/fb_graph/connections/noreply.rb +1 -5
- data/lib/fb_graph/event.rb +19 -9
- data/lib/fb_graph/group.rb +1 -1
- data/lib/fb_graph/link.rb +1 -1
- data/lib/fb_graph/node.rb +26 -26
- data/lib/fb_graph/note.rb +2 -2
- data/lib/fb_graph/photo.rb +11 -8
- data/lib/fb_graph/post.rb +2 -2
- data/lib/fb_graph/status.rb +1 -1
- data/lib/fb_graph/tag.rb +1 -1
- data/lib/fb_graph/user.rb +3 -1
- data/lib/fb_graph/video.rb +2 -2
- data/lib/fb_graph.rb +11 -6
- data/spec/fake_json/albums/photos/matake_private.json +97 -0
- data/spec/fake_json/albums/photos/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/events/attending/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/events/attending/smartday_private.json +44 -0
- data/spec/fake_json/events/declined/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/events/declined/smartday_private.json +720 -0
- data/spec/fake_json/events/invited/smartday_private.json +7092 -0
- data/spec/fake_json/events/maybe/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/events/maybe/smartday_private.json +956 -0
- data/spec/fake_json/events/noreply/smartday_private.json +896 -0
- data/spec/fake_json/groups/members/emacs_private.json +1996 -0
- data/spec/fake_json/pages/notes/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/posts/comments/post_with_invalid_access_token.json +1 -0
- data/spec/fake_json/posts/comments/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/posts/comments/post_without_access_token.json +1 -0
- data/spec/fake_json/posts/likes/post_with_invalid_access_token.json +1 -0
- data/spec/fake_json/posts/likes/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/posts/likes/post_without_access_token.json +1 -0
- data/spec/fake_json/users/albums/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/users/events/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/users/feed/post_with_invalid_access_token.json +1 -0
- data/spec/fake_json/users/feed/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/users/feed/post_without_access_token.json +1 -0
- data/spec/fake_json/users/interests/matake_private.json +14 -0
- data/spec/fake_json/users/links/matake_private.json +221 -0
- data/spec/fake_json/users/links/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/users/movies/matake_private.json +9 -0
- data/spec/fake_json/users/music/matake_private.json +34 -0
- data/spec/fake_json/users/notes/matake_private.json +308 -0
- data/spec/fake_json/users/television/matake_private.json +9 -0
- data/spec/fake_json/users/videos/kirk_private.json +41 -0
- data/spec/fb_graph/album_spec.rb +1 -1
- data/spec/fb_graph/collection_spec.rb +1 -1
- data/spec/fb_graph/comment_spec.rb +1 -1
- data/spec/fb_graph/connections/activities_spec.rb +2 -2
- data/spec/fb_graph/connections/albums_spec.rb +18 -2
- data/spec/fb_graph/connections/attending_spec.rb +24 -0
- data/spec/fb_graph/connections/comments_spec.rb +83 -0
- data/spec/fb_graph/connections/declined_spec.rb +24 -0
- data/spec/fb_graph/connections/events_spec.rb +20 -2
- data/spec/fb_graph/connections/feed_spec.rb +42 -2
- data/spec/fb_graph/connections/interests_spec.rb +14 -0
- data/spec/fb_graph/connections/invited_spec.rb +14 -0
- data/spec/fb_graph/connections/likes_spec.rb +2 -2
- data/spec/fb_graph/connections/links_spec.rb +32 -0
- data/spec/fb_graph/connections/maybe_spec.rb +24 -0
- data/spec/fb_graph/connections/members_spec.rb +14 -0
- data/spec/fb_graph/connections/movies_spec.rb +14 -0
- data/spec/fb_graph/connections/music_spec.rb +14 -0
- data/spec/fb_graph/connections/noreply_spec.rb +14 -0
- data/spec/fb_graph/connections/notes_spec.rb +31 -0
- data/spec/fb_graph/connections/photos_spec.rb +29 -0
- data/spec/fb_graph/connections/television_spec.rb +14 -0
- data/spec/fb_graph/connections/videos_spec.rb +14 -0
- data/spec/fb_graph/education_spec.rb +1 -1
- data/spec/fb_graph/event_spec.rb +1 -1
- data/spec/fb_graph/group_spec.rb +1 -1
- data/spec/fb_graph/link_spec.rb +1 -1
- data/spec/fb_graph/node_spec.rb +1 -1
- data/spec/fb_graph/note_spec.rb +1 -1
- data/spec/fb_graph/photo_spec.rb +1 -1
- data/spec/fb_graph/post_spec.rb +1 -1
- data/spec/fb_graph/status_spec.rb +1 -1
- data/spec/fb_graph/tag_spec.rb +1 -1
- data/spec/fb_graph/user_spec.rb +9 -0
- data/spec/fb_graph/venue_spec.rb +1 -1
- data/spec/fb_graph/video_spec.rb +1 -1
- data/spec/fb_graph/work_spec.rb +1 -1
- data/spec/helpers/fake_json_helper.rb +4 -2
- metadata +64 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/fb_graph.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{fb_graph}
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["nov matake"]
|
12
|
-
s.date = %q{2010-05-
|
12
|
+
s.date = %q{2010-05-11}
|
13
13
|
s.description = %q{A Ruby wrapper for Facebook Graph API}
|
14
14
|
s.email = %q{nov@matake.jp}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -75,24 +75,47 @@ Gem::Specification.new do |s|
|
|
75
75
|
"lib/fb_graph/venue.rb",
|
76
76
|
"lib/fb_graph/video.rb",
|
77
77
|
"lib/fb_graph/work.rb",
|
78
|
+
"spec/fake_json/albums/photos/matake_private.json",
|
79
|
+
"spec/fake_json/albums/photos/post_with_valid_access_token.json",
|
80
|
+
"spec/fake_json/events/attending/post_with_valid_access_token.json",
|
81
|
+
"spec/fake_json/events/attending/smartday_private.json",
|
82
|
+
"spec/fake_json/events/declined/post_with_valid_access_token.json",
|
83
|
+
"spec/fake_json/events/declined/smartday_private.json",
|
84
|
+
"spec/fake_json/events/invited/smartday_private.json",
|
85
|
+
"spec/fake_json/events/maybe/post_with_valid_access_token.json",
|
86
|
+
"spec/fake_json/events/maybe/smartday_private.json",
|
87
|
+
"spec/fake_json/events/noreply/smartday_private.json",
|
88
|
+
"spec/fake_json/groups/members/emacs_private.json",
|
89
|
+
"spec/fake_json/pages/notes/post_with_valid_access_token.json",
|
78
90
|
"spec/fake_json/pages/platform_private.json",
|
79
91
|
"spec/fake_json/pages/platform_public.json",
|
80
92
|
"spec/fake_json/pages/statuses/platform_private.json",
|
81
93
|
"spec/fake_json/pages/statuses/platform_public.json",
|
94
|
+
"spec/fake_json/posts/comments/post_with_invalid_access_token.json",
|
95
|
+
"spec/fake_json/posts/comments/post_with_valid_access_token.json",
|
96
|
+
"spec/fake_json/posts/comments/post_without_access_token.json",
|
97
|
+
"spec/fake_json/posts/likes/post_with_invalid_access_token.json",
|
98
|
+
"spec/fake_json/posts/likes/post_with_valid_access_token.json",
|
99
|
+
"spec/fake_json/posts/likes/post_without_access_token.json",
|
82
100
|
"spec/fake_json/posts/platform_private.json",
|
83
101
|
"spec/fake_json/posts/platform_public.json",
|
84
102
|
"spec/fake_json/users/activities/arjun_private.json",
|
85
103
|
"spec/fake_json/users/activities/arjun_public.json",
|
86
104
|
"spec/fake_json/users/albums/matake_private.json",
|
87
105
|
"spec/fake_json/users/albums/matake_public.json",
|
106
|
+
"spec/fake_json/users/albums/post_with_valid_access_token.json",
|
88
107
|
"spec/fake_json/users/arjun_private.json",
|
89
108
|
"spec/fake_json/users/arjun_public.json",
|
90
109
|
"spec/fake_json/users/books/matake_private.json",
|
91
110
|
"spec/fake_json/users/books/matake_public.json",
|
92
111
|
"spec/fake_json/users/events/matake_private.json",
|
93
112
|
"spec/fake_json/users/events/matake_public.json",
|
113
|
+
"spec/fake_json/users/events/post_with_valid_access_token.json",
|
94
114
|
"spec/fake_json/users/feed/arjun_private.json",
|
95
115
|
"spec/fake_json/users/feed/arjun_public.json",
|
116
|
+
"spec/fake_json/users/feed/post_with_invalid_access_token.json",
|
117
|
+
"spec/fake_json/users/feed/post_with_valid_access_token.json",
|
118
|
+
"spec/fake_json/users/feed/post_without_access_token.json",
|
96
119
|
"spec/fake_json/users/friends/arjun_private.json",
|
97
120
|
"spec/fake_json/users/friends/arjun_public.json",
|
98
121
|
"spec/fake_json/users/friends/me_private.json",
|
@@ -105,32 +128,55 @@ Gem::Specification.new do |s|
|
|
105
128
|
"spec/fake_json/users/home/me_private_next.json",
|
106
129
|
"spec/fake_json/users/home/me_private_previous.json",
|
107
130
|
"spec/fake_json/users/home/me_public.json",
|
131
|
+
"spec/fake_json/users/interests/matake_private.json",
|
108
132
|
"spec/fake_json/users/likes/arjun_private.json",
|
109
133
|
"spec/fake_json/users/likes/arjun_public.json",
|
134
|
+
"spec/fake_json/users/links/matake_private.json",
|
135
|
+
"spec/fake_json/users/links/post_with_valid_access_token.json",
|
110
136
|
"spec/fake_json/users/me_private.json",
|
111
137
|
"spec/fake_json/users/me_public.json",
|
138
|
+
"spec/fake_json/users/movies/matake_private.json",
|
139
|
+
"spec/fake_json/users/music/matake_private.json",
|
140
|
+
"spec/fake_json/users/notes/matake_private.json",
|
112
141
|
"spec/fake_json/users/posts/arjun_private.json",
|
113
142
|
"spec/fake_json/users/posts/arjun_public.json",
|
114
143
|
"spec/fake_json/users/statuses/arjun_private.json",
|
115
144
|
"spec/fake_json/users/statuses/arjun_public.json",
|
116
145
|
"spec/fake_json/users/tagged/arjun_private.json",
|
117
146
|
"spec/fake_json/users/tagged/arjun_public.json",
|
147
|
+
"spec/fake_json/users/television/matake_private.json",
|
148
|
+
"spec/fake_json/users/videos/kirk_private.json",
|
118
149
|
"spec/fb_graph/album_spec.rb",
|
119
150
|
"spec/fb_graph/collection_spec.rb",
|
120
151
|
"spec/fb_graph/comment_spec.rb",
|
121
152
|
"spec/fb_graph/connections/activities_spec.rb",
|
122
153
|
"spec/fb_graph/connections/albums_spec.rb",
|
154
|
+
"spec/fb_graph/connections/attending_spec.rb",
|
123
155
|
"spec/fb_graph/connections/books_spec.rb",
|
156
|
+
"spec/fb_graph/connections/comments_spec.rb",
|
157
|
+
"spec/fb_graph/connections/declined_spec.rb",
|
124
158
|
"spec/fb_graph/connections/events_spec.rb",
|
125
159
|
"spec/fb_graph/connections/feed_spec.rb",
|
126
160
|
"spec/fb_graph/connections/friends_spec.rb",
|
127
161
|
"spec/fb_graph/connections/groups_spec.rb",
|
128
162
|
"spec/fb_graph/connections/home_spec.rb",
|
163
|
+
"spec/fb_graph/connections/interests_spec.rb",
|
164
|
+
"spec/fb_graph/connections/invited_spec.rb",
|
129
165
|
"spec/fb_graph/connections/likes_spec.rb",
|
166
|
+
"spec/fb_graph/connections/links_spec.rb",
|
167
|
+
"spec/fb_graph/connections/maybe_spec.rb",
|
168
|
+
"spec/fb_graph/connections/members_spec.rb",
|
169
|
+
"spec/fb_graph/connections/movies_spec.rb",
|
170
|
+
"spec/fb_graph/connections/music_spec.rb",
|
171
|
+
"spec/fb_graph/connections/noreply_spec.rb",
|
172
|
+
"spec/fb_graph/connections/notes_spec.rb",
|
173
|
+
"spec/fb_graph/connections/photos_spec.rb",
|
130
174
|
"spec/fb_graph/connections/picture_spec.rb",
|
131
175
|
"spec/fb_graph/connections/posts_spec.rb",
|
132
176
|
"spec/fb_graph/connections/statuses_spec.rb",
|
133
177
|
"spec/fb_graph/connections/tagged_spec.rb",
|
178
|
+
"spec/fb_graph/connections/television_spec.rb",
|
179
|
+
"spec/fb_graph/connections/videos_spec.rb",
|
134
180
|
"spec/fb_graph/education_spec.rb",
|
135
181
|
"spec/fb_graph/event_spec.rb",
|
136
182
|
"spec/fb_graph/group_spec.rb",
|
@@ -162,17 +208,32 @@ Gem::Specification.new do |s|
|
|
162
208
|
"spec/fb_graph/comment_spec.rb",
|
163
209
|
"spec/fb_graph/connections/activities_spec.rb",
|
164
210
|
"spec/fb_graph/connections/albums_spec.rb",
|
211
|
+
"spec/fb_graph/connections/attending_spec.rb",
|
165
212
|
"spec/fb_graph/connections/books_spec.rb",
|
213
|
+
"spec/fb_graph/connections/comments_spec.rb",
|
214
|
+
"spec/fb_graph/connections/declined_spec.rb",
|
166
215
|
"spec/fb_graph/connections/events_spec.rb",
|
167
216
|
"spec/fb_graph/connections/feed_spec.rb",
|
168
217
|
"spec/fb_graph/connections/friends_spec.rb",
|
169
218
|
"spec/fb_graph/connections/groups_spec.rb",
|
170
219
|
"spec/fb_graph/connections/home_spec.rb",
|
220
|
+
"spec/fb_graph/connections/interests_spec.rb",
|
221
|
+
"spec/fb_graph/connections/invited_spec.rb",
|
171
222
|
"spec/fb_graph/connections/likes_spec.rb",
|
223
|
+
"spec/fb_graph/connections/links_spec.rb",
|
224
|
+
"spec/fb_graph/connections/maybe_spec.rb",
|
225
|
+
"spec/fb_graph/connections/members_spec.rb",
|
226
|
+
"spec/fb_graph/connections/movies_spec.rb",
|
227
|
+
"spec/fb_graph/connections/music_spec.rb",
|
228
|
+
"spec/fb_graph/connections/noreply_spec.rb",
|
229
|
+
"spec/fb_graph/connections/notes_spec.rb",
|
230
|
+
"spec/fb_graph/connections/photos_spec.rb",
|
172
231
|
"spec/fb_graph/connections/picture_spec.rb",
|
173
232
|
"spec/fb_graph/connections/posts_spec.rb",
|
174
233
|
"spec/fb_graph/connections/statuses_spec.rb",
|
175
234
|
"spec/fb_graph/connections/tagged_spec.rb",
|
235
|
+
"spec/fb_graph/connections/television_spec.rb",
|
236
|
+
"spec/fb_graph/connections/videos_spec.rb",
|
176
237
|
"spec/fb_graph/education_spec.rb",
|
177
238
|
"spec/fb_graph/event_spec.rb",
|
178
239
|
"spec/fb_graph/group_spec.rb",
|
data/lib/fb_graph/album.rb
CHANGED
@@ -15,15 +15,18 @@ module FbGraph
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
@name = options[:name]
|
18
|
-
|
18
|
+
# NOTE:
|
19
|
+
# for some reason, facebook uses different parameter names.
|
20
|
+
# "description" in GET & "message" in POST
|
21
|
+
@description = options[:description] || options[:message]
|
19
22
|
@location = options[:location]
|
20
23
|
@link = options[:link]
|
21
24
|
@count = options[:count]
|
22
25
|
if options[:created_time]
|
23
|
-
@created_time = Time.parse(options[:created_time])
|
26
|
+
@created_time = Time.parse(options[:created_time]).utc
|
24
27
|
end
|
25
28
|
if options[:updated_time]
|
26
|
-
@updated_time = Time.parse(options[:updated_time])
|
29
|
+
@updated_time = Time.parse(options[:updated_time]).utc
|
27
30
|
end
|
28
31
|
end
|
29
32
|
end
|
data/lib/fb_graph/comment.rb
CHANGED
@@ -4,11 +4,7 @@ module FbGraph
|
|
4
4
|
def attending(options = {})
|
5
5
|
members = FbGraph::Collection.new(get(options.merge(:connection => 'attending')))
|
6
6
|
members.map! do |member|
|
7
|
-
|
8
|
-
Page.new(member.delete(:id), member)
|
9
|
-
else
|
10
|
-
User.new(member.delete(:id), member)
|
11
|
-
end
|
7
|
+
User.new(member.delete(:id), member)
|
12
8
|
end
|
13
9
|
end
|
14
10
|
|
@@ -4,11 +4,7 @@ module FbGraph
|
|
4
4
|
def declined(options = {})
|
5
5
|
members = FbGraph::Collection.new(get(options.merge(:connection => 'declined')))
|
6
6
|
members.map! do |member|
|
7
|
-
|
8
|
-
Page.new(member.delete(:id), member)
|
9
|
-
else
|
10
|
-
User.new(member.delete(:id), member)
|
11
|
-
end
|
7
|
+
User.new(member.delete(:id), member)
|
12
8
|
end
|
13
9
|
end
|
14
10
|
|
@@ -4,11 +4,7 @@ module FbGraph
|
|
4
4
|
def invited(options = {})
|
5
5
|
members = FbGraph::Collection.new(get(options.merge(:connection => 'invited')))
|
6
6
|
members.map! do |member|
|
7
|
-
|
8
|
-
Page.new(member.delete(:id), member)
|
9
|
-
else
|
10
|
-
User.new(member.delete(:id), member)
|
11
|
-
end
|
7
|
+
User.new(member.delete(:id), member)
|
12
8
|
end
|
13
9
|
end
|
14
10
|
end
|
@@ -4,11 +4,7 @@ module FbGraph
|
|
4
4
|
def maybe(options = {})
|
5
5
|
members = FbGraph::Collection.new(get(options.merge(:connection => 'maybe')))
|
6
6
|
members.map! do |member|
|
7
|
-
|
8
|
-
Page.new(member.delete(:id), member)
|
9
|
-
else
|
10
|
-
User.new(member.delete(:id), member)
|
11
|
-
end
|
7
|
+
User.new(member.delete(:id), member)
|
12
8
|
end
|
13
9
|
end
|
14
10
|
|
@@ -3,12 +3,8 @@ module FbGraph
|
|
3
3
|
module Members
|
4
4
|
def members(options = {})
|
5
5
|
members = FbGraph::Collection.new(get(options.merge(:connection => 'members')))
|
6
|
-
|
7
|
-
|
8
|
-
Page.new(member.delete(:id), member)
|
9
|
-
else
|
10
|
-
User.new(member.delete(:id), member)
|
11
|
-
end
|
6
|
+
members.map! do |member|
|
7
|
+
User.new(member.delete(:id), member)
|
12
8
|
end
|
13
9
|
end
|
14
10
|
end
|
@@ -4,11 +4,7 @@ module FbGraph
|
|
4
4
|
def noreply(options = {})
|
5
5
|
members = FbGraph::Collection.new(get(options.merge(:connection => 'noreply')))
|
6
6
|
members.map! do |member|
|
7
|
-
|
8
|
-
Page.new(member.delete(:id), member)
|
9
|
-
else
|
10
|
-
User.new(member.delete(:id), member)
|
11
|
-
end
|
7
|
+
User.new(member.delete(:id), member)
|
12
8
|
end
|
13
9
|
end
|
14
10
|
end
|
data/lib/fb_graph/event.rb
CHANGED
@@ -15,21 +15,31 @@ module FbGraph
|
|
15
15
|
if (owner = options[:owner])
|
16
16
|
@owner = FbGraph::User.new(owner.delete(:id), owner)
|
17
17
|
end
|
18
|
-
@name
|
19
|
-
@description
|
20
|
-
|
21
|
-
|
18
|
+
@name = options[:name]
|
19
|
+
@description = options[:description]
|
20
|
+
@location = options[:location]
|
21
|
+
@privacy = options[:privacy]
|
22
|
+
if (start_time = options[:start_time])
|
23
|
+
@start_time = case start_time
|
24
|
+
when String
|
25
|
+
Time.parse(start_time).utc
|
26
|
+
when Fixnum
|
27
|
+
Time.at(start_time).utc
|
28
|
+
end
|
22
29
|
end
|
23
|
-
if options[:end_time]
|
24
|
-
@end_time =
|
30
|
+
if (end_time = options[:end_time])
|
31
|
+
@end_time = case end_time
|
32
|
+
when String
|
33
|
+
Time.parse(end_time).utc
|
34
|
+
when Fixnum
|
35
|
+
Time.at(end_time).utc
|
36
|
+
end
|
25
37
|
end
|
26
|
-
@location = options[:location]
|
27
|
-
@privacy = options[:privacy]
|
28
38
|
if options[:venue]
|
29
39
|
@venue = FbGraph::Venue.new(options[:venue])
|
30
40
|
end
|
31
41
|
if options[:updated_time]
|
32
|
-
@updated_time = Time.parse(options[:updated_time])
|
42
|
+
@updated_time = Time.parse(options[:updated_time]).utc
|
33
43
|
end
|
34
44
|
end
|
35
45
|
end
|
data/lib/fb_graph/group.rb
CHANGED
data/lib/fb_graph/link.rb
CHANGED
data/lib/fb_graph/node.rb
CHANGED
@@ -27,52 +27,50 @@ module FbGraph
|
|
27
27
|
|
28
28
|
protected
|
29
29
|
|
30
|
-
def get(
|
31
|
-
_endpoint_ = build_endpoint(
|
32
|
-
handle_response
|
33
|
-
|
34
|
-
|
30
|
+
def get(params = {})
|
31
|
+
_endpoint_ = build_endpoint(params.merge!(:method => :get))
|
32
|
+
handle_response do
|
33
|
+
RestClient.get(_endpoint_)
|
34
|
+
end
|
35
35
|
end
|
36
36
|
|
37
|
-
def post(
|
38
|
-
_endpoint_ = build_endpoint(
|
39
|
-
handle_response
|
40
|
-
|
41
|
-
|
42
|
-
raise FbGraph::Exception.new(e.http_code, e.message, e.http_body)
|
37
|
+
def post(params = {})
|
38
|
+
_endpoint_ = build_endpoint(params.merge!(:method => :post))
|
39
|
+
handle_response do
|
40
|
+
RestClient.post(_endpoint_, params)
|
41
|
+
end
|
43
42
|
end
|
44
43
|
|
45
|
-
def delete(
|
46
|
-
_endpoint_ = build_endpoint(
|
47
|
-
handle_response
|
48
|
-
|
49
|
-
|
44
|
+
def delete(params = {})
|
45
|
+
_endpoint_ = build_endpoint(params.merge!(:method => :delete))
|
46
|
+
handle_response do
|
47
|
+
RestClient.delete(_endpoint_, params)
|
48
|
+
end
|
50
49
|
end
|
51
50
|
|
52
51
|
private
|
53
52
|
|
54
|
-
def build_endpoint(
|
55
|
-
_endpoint_ = if
|
56
|
-
File.join(self.endpoint,
|
53
|
+
def build_endpoint(params = {})
|
54
|
+
_endpoint_ = if params[:connection]
|
55
|
+
File.join(self.endpoint, params.delete(:connection))
|
57
56
|
else
|
58
57
|
self.endpoint
|
59
58
|
end
|
60
|
-
|
61
|
-
|
59
|
+
params[:access_token] ||= self.access_token
|
60
|
+
params.delete_if do |k, v|
|
62
61
|
v.blank?
|
63
62
|
end
|
64
|
-
if
|
65
|
-
_endpoint_ << "?#{
|
63
|
+
if params.delete(:method) == :get && params.present?
|
64
|
+
_endpoint_ << "?#{params.to_query}"
|
66
65
|
end
|
67
66
|
_endpoint_
|
68
67
|
end
|
69
68
|
|
70
|
-
def handle_response
|
69
|
+
def handle_response
|
70
|
+
response = yield
|
71
71
|
case response.body
|
72
72
|
when 'true'
|
73
73
|
true
|
74
|
-
when 'false'
|
75
|
-
false
|
76
74
|
else
|
77
75
|
_response_ = JSON.parse(response.body).with_indifferent_access
|
78
76
|
if _response_[:error]
|
@@ -88,6 +86,8 @@ module FbGraph
|
|
88
86
|
_response_
|
89
87
|
end
|
90
88
|
end
|
89
|
+
rescue RestClient::Exception => e
|
90
|
+
raise FbGraph::Exception.new(e.http_code, e.message, e.http_body)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
data/lib/fb_graph/note.rb
CHANGED
@@ -16,10 +16,10 @@ module FbGraph
|
|
16
16
|
@subject = options[:subject]
|
17
17
|
@message = options[:message]
|
18
18
|
if options[:created_time]
|
19
|
-
@created_time = Time.parse(options[:created_time])
|
19
|
+
@created_time = Time.parse(options[:created_time]).utc
|
20
20
|
end
|
21
21
|
if options[:updated_time]
|
22
|
-
@updated_time = Time.parse(options[:updated_time])
|
22
|
+
@updated_time = Time.parse(options[:updated_time]).utc
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
data/lib/fb_graph/photo.rb
CHANGED
@@ -19,17 +19,20 @@ module FbGraph
|
|
19
19
|
@tags << FbGraph::Tag.new(tag.delete(:id), tag)
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
22
|
+
# NOTE:
|
23
|
+
# for some reason, facebook uses different parameter names.
|
24
|
+
# "name" in GET & "message" in POST
|
25
|
+
@name = options[:name] || options[:message]
|
26
|
+
@picture = options[:picture]
|
27
|
+
@source = options[:source]
|
28
|
+
@height = options[:height]
|
29
|
+
@width = options[:width]
|
30
|
+
@link = options[:link]
|
28
31
|
if options[:created_time]
|
29
|
-
@created_time = Time.parse(options[:created_time])
|
32
|
+
@created_time = Time.parse(options[:created_time]).utc
|
30
33
|
end
|
31
34
|
if options[:updated_time]
|
32
|
-
@updated_time = Time.parse(options[:updated_time])
|
35
|
+
@updated_time = Time.parse(options[:updated_time]).utc
|
33
36
|
end
|
34
37
|
end
|
35
38
|
end
|
data/lib/fb_graph/post.rb
CHANGED
@@ -35,10 +35,10 @@ module FbGraph
|
|
35
35
|
@actions = options[:actions]
|
36
36
|
@likes = options[:likes]
|
37
37
|
if options[:created_time]
|
38
|
-
@created_time = Time.parse(options[:created_time])
|
38
|
+
@created_time = Time.parse(options[:created_time]).utc
|
39
39
|
end
|
40
40
|
if options[:updated_time]
|
41
|
-
@updated_time = Time.parse(options[:updated_time])
|
41
|
+
@updated_time = Time.parse(options[:updated_time]).utc
|
42
42
|
end
|
43
43
|
|
44
44
|
# cached connection
|
data/lib/fb_graph/status.rb
CHANGED
data/lib/fb_graph/tag.rb
CHANGED
@@ -8,7 +8,7 @@ module FbGraph
|
|
8
8
|
@x = options.delete(:x)
|
9
9
|
@y = options.delete(:y)
|
10
10
|
if (created_time = options.delete(:created_time))
|
11
|
-
@created_time = Time.parse(created_time)
|
11
|
+
@created_time = Time.parse(created_time).utc
|
12
12
|
end
|
13
13
|
@user = User.new(identifier, options)
|
14
14
|
end
|
data/lib/fb_graph/user.rb
CHANGED
@@ -38,7 +38,9 @@ module FbGraph
|
|
38
38
|
@about = options[:about]
|
39
39
|
@email = options[:email]
|
40
40
|
if options[:birthday]
|
41
|
-
|
41
|
+
month, day, year = options[:birthday].split('/').collect(&:to_i)
|
42
|
+
year ||= 0
|
43
|
+
@birthday = Date.new(year, month, day)
|
42
44
|
end
|
43
45
|
@work = []
|
44
46
|
if options[:work]
|
data/lib/fb_graph/video.rb
CHANGED
@@ -17,10 +17,10 @@ module FbGraph
|
|
17
17
|
@description = options[:description]
|
18
18
|
@length = options[:length]
|
19
19
|
if options[:created_time]
|
20
|
-
@created_time = Time.parse(options[:created_time])
|
20
|
+
@created_time = Time.parse(options[:created_time]).utc
|
21
21
|
end
|
22
22
|
if options[:updated_time]
|
23
|
-
@updated_time = Time.parse(options[:updated_time])
|
23
|
+
@updated_time = Time.parse(options[:updated_time]).utc
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/lib/fb_graph.rb
CHANGED
@@ -6,16 +6,21 @@ require 'restclient'
|
|
6
6
|
module FbGraph
|
7
7
|
ROOT_URL = "https://graph.facebook.com"
|
8
8
|
|
9
|
-
class
|
10
|
-
attr_accessor :code, :
|
9
|
+
class Exception < StandardError
|
10
|
+
attr_accessor :code, :type, :message
|
11
11
|
def initialize(code, message, body = '')
|
12
12
|
@code = code
|
13
|
-
|
14
|
-
|
13
|
+
if body.blank?
|
14
|
+
@message = message
|
15
|
+
else
|
16
|
+
response = JSON.parse(body).with_indifferent_access
|
17
|
+
@message = response[:error][:message]
|
18
|
+
@type = response[:error][:type]
|
19
|
+
end
|
15
20
|
end
|
16
21
|
end
|
17
|
-
class
|
18
|
-
class
|
22
|
+
class Unauthorized < FbGraph::Exception; end
|
23
|
+
class NotFound < FbGraph::Exception; end
|
19
24
|
|
20
25
|
class << self
|
21
26
|
def node(identifier, options = {})
|
@@ -0,0 +1,97 @@
|
|
1
|
+
{
|
2
|
+
"data": [
|
3
|
+
{
|
4
|
+
"id": "1257916083644",
|
5
|
+
"from": {
|
6
|
+
"name": "Miwa Nagamitsu",
|
7
|
+
"id": "1101885111"
|
8
|
+
},
|
9
|
+
"tags": {
|
10
|
+
"data": [
|
11
|
+
{
|
12
|
+
"id": "579612276",
|
13
|
+
"name": "Nov Matake",
|
14
|
+
"x": 58,
|
15
|
+
"y": 42,
|
16
|
+
"created_time": "2009-11-27T15:14:12+0000"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"id": "",
|
20
|
+
"name": "Kondo",
|
21
|
+
"x": 50,
|
22
|
+
"y": 8,
|
23
|
+
"created_time": "2009-11-27T15:14:20+0000"
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"id": "",
|
27
|
+
"name": "Hiromi",
|
28
|
+
"x": 20,
|
29
|
+
"y": 6,
|
30
|
+
"created_time": "2009-11-27T15:14:41+0000"
|
31
|
+
}
|
32
|
+
]
|
33
|
+
},
|
34
|
+
"name": "Kondo!!",
|
35
|
+
"picture": "http://photos-b.ak.fbcdn.net/hphotos-ak-snc3/hs063.snc3/13041_1257916083644_1101885111_822884_3913995_s.jpg",
|
36
|
+
"source": "http://sphotos.ak.fbcdn.net/hphotos-ak-sjc1/hs063.snc3/13041_1257916083644_1101885111_822884_3913995_n.jpg",
|
37
|
+
"height": 453,
|
38
|
+
"width": 604,
|
39
|
+
"link": "http://www.facebook.com/photo.php?pid=822884&id=1101885111",
|
40
|
+
"icon": "http://static.ak.fbcdn.net/rsrc.php/z2E5Y/hash/8as8iqdm.gif",
|
41
|
+
"created_time": "2009-11-27T14:54:46+0000",
|
42
|
+
"updated_time": "2009-11-27T14:54:48+0000"
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"id": "1257914963616",
|
46
|
+
"from": {
|
47
|
+
"name": "Miwa Nagamitsu",
|
48
|
+
"id": "1101885111"
|
49
|
+
},
|
50
|
+
"tags": {
|
51
|
+
"data": [
|
52
|
+
{
|
53
|
+
"id": "",
|
54
|
+
"name": "Eric",
|
55
|
+
"x": 41,
|
56
|
+
"y": 14,
|
57
|
+
"created_time": "2009-11-27T15:11:02+0000"
|
58
|
+
},
|
59
|
+
{
|
60
|
+
"id": "",
|
61
|
+
"name": "Hiromi",
|
62
|
+
"x": 68,
|
63
|
+
"y": 34,
|
64
|
+
"created_time": "2009-11-27T15:11:42+0000"
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"id": "",
|
68
|
+
"name": "Kondo",
|
69
|
+
"x": 88,
|
70
|
+
"y": 55,
|
71
|
+
"created_time": "2009-11-27T15:11:50+0000"
|
72
|
+
},
|
73
|
+
{
|
74
|
+
"id": "579612276",
|
75
|
+
"name": "Nov Matake",
|
76
|
+
"x": 49,
|
77
|
+
"y": 67,
|
78
|
+
"created_time": "2009-11-27T15:11:59+0000"
|
79
|
+
}
|
80
|
+
]
|
81
|
+
},
|
82
|
+
"name": "Otsukare party!",
|
83
|
+
"picture": "http://photos-g.ak.fbcdn.net/hphotos-ak-snc3/hs043.snc3/13041_1257914963616_1101885111_822881_5331358_s.jpg",
|
84
|
+
"source": "http://sphotos.ak.fbcdn.net/hphotos-ak-snc3/hs043.snc3/13041_1257914963616_1101885111_822881_5331358_n.jpg",
|
85
|
+
"height": 453,
|
86
|
+
"width": 604,
|
87
|
+
"link": "http://www.facebook.com/photo.php?pid=822881&id=1101885111",
|
88
|
+
"icon": "http://static.ak.fbcdn.net/rsrc.php/z2E5Y/hash/8as8iqdm.gif",
|
89
|
+
"created_time": "2009-11-27T14:52:44+0000",
|
90
|
+
"updated_time": "2009-11-27T14:52:44+0000"
|
91
|
+
}
|
92
|
+
],
|
93
|
+
"paging": {
|
94
|
+
"previous": "https://graph.facebook.com/579612276/photos?access_token=2227470867%7C2.RCvMPAuqsf2uaQr7YizV2Q__.3600.1273557600-579612276%7CwzBo6c2HKRjURbEaVGt0F2kNRbQ.&limit=25&since=2009-11-27T14%3A54%3A46%2B0000",
|
95
|
+
"next": "https://graph.facebook.com/579612276/photos?access_token=2227470867%7C2.RCvMPAuqsf2uaQr7YizV2Q__.3600.1273557600-579612276%7CwzBo6c2HKRjURbEaVGt0F2kNRbQ.&limit=25&until=2009-11-27T14%3A52%3A44%2B0000"
|
96
|
+
}
|
97
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"id":401111132276}
|