tenderlove-facebooker 1.0.16.20090319151701
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +17 -0
- data/COPYING.rdoc +19 -0
- data/Manifest.txt +123 -0
- data/README.rdoc +103 -0
- data/Rakefile +86 -0
- data/TODO.rdoc +4 -0
- data/examples/desktop_login.rb +14 -0
- data/facebooker.gemspec +38 -0
- data/generators/facebook/facebook_generator.rb +14 -0
- data/generators/facebook/templates/config/facebooker.yml +46 -0
- data/generators/facebook/templates/public/javascripts/facebooker.js +99 -0
- data/generators/facebook_controller/USAGE +33 -0
- data/generators/facebook_controller/facebook_controller_generator.rb +40 -0
- data/generators/facebook_controller/templates/controller.rb +7 -0
- data/generators/facebook_controller/templates/functional_test.rb +11 -0
- data/generators/facebook_controller/templates/helper.rb +2 -0
- data/generators/facebook_controller/templates/view.fbml.erb +2 -0
- data/generators/facebook_controller/templates/view.html.erb +2 -0
- data/generators/facebook_publisher/facebook_publisher_generator.rb +14 -0
- data/generators/facebook_publisher/templates/create_facebook_templates.rb +15 -0
- data/generators/facebook_publisher/templates/publisher.rb +3 -0
- data/generators/facebook_scaffold/USAGE +27 -0
- data/generators/facebook_scaffold/facebook_scaffold_generator.rb +118 -0
- data/generators/facebook_scaffold/templates/controller.rb +93 -0
- data/generators/facebook_scaffold/templates/facebook_style.css +2579 -0
- data/generators/facebook_scaffold/templates/functional_test.rb +89 -0
- data/generators/facebook_scaffold/templates/helper.rb +2 -0
- data/generators/facebook_scaffold/templates/layout.fbml.erb +6 -0
- data/generators/facebook_scaffold/templates/layout.html.erb +17 -0
- data/generators/facebook_scaffold/templates/style.css +74 -0
- data/generators/facebook_scaffold/templates/view_edit.fbml.erb +13 -0
- data/generators/facebook_scaffold/templates/view_edit.html.erb +18 -0
- data/generators/facebook_scaffold/templates/view_index.fbml.erb +24 -0
- data/generators/facebook_scaffold/templates/view_index.html.erb +24 -0
- data/generators/facebook_scaffold/templates/view_new.fbml.erb +12 -0
- data/generators/facebook_scaffold/templates/view_new.html.erb +17 -0
- data/generators/facebook_scaffold/templates/view_show.fbml.erb +10 -0
- data/generators/facebook_scaffold/templates/view_show.html.erb +10 -0
- data/generators/publisher/publisher_generator.rb +14 -0
- data/generators/xd_receiver/templates/xd_receiver.html +10 -0
- data/generators/xd_receiver/xd_receiver_generator.rb +9 -0
- data/init.rb +72 -0
- data/install.rb +12 -0
- data/lib/facebooker/adapters/adapter_base.rb +87 -0
- data/lib/facebooker/adapters/bebo_adapter.rb +75 -0
- data/lib/facebooker/adapters/facebook_adapter.rb +52 -0
- data/lib/facebooker/admin.rb +42 -0
- data/lib/facebooker/batch_request.rb +44 -0
- data/lib/facebooker/data.rb +57 -0
- data/lib/facebooker/feed.rb +78 -0
- data/lib/facebooker/logging.rb +51 -0
- data/lib/facebooker/mobile.rb +20 -0
- data/lib/facebooker/mock/service.rb +50 -0
- data/lib/facebooker/mock/session.rb +18 -0
- data/lib/facebooker/model.rb +135 -0
- data/lib/facebooker/models/affiliation.rb +10 -0
- data/lib/facebooker/models/album.rb +11 -0
- data/lib/facebooker/models/applicationproperties.rb +39 -0
- data/lib/facebooker/models/applicationrestrictions.rb +10 -0
- data/lib/facebooker/models/cookie.rb +10 -0
- data/lib/facebooker/models/education_info.rb +11 -0
- data/lib/facebooker/models/event.rb +28 -0
- data/lib/facebooker/models/friend_list.rb +16 -0
- data/lib/facebooker/models/group.rb +36 -0
- data/lib/facebooker/models/info_item.rb +10 -0
- data/lib/facebooker/models/info_section.rb +10 -0
- data/lib/facebooker/models/location.rb +8 -0
- data/lib/facebooker/models/notifications.rb +17 -0
- data/lib/facebooker/models/page.rb +27 -0
- data/lib/facebooker/models/photo.rb +12 -0
- data/lib/facebooker/models/tag.rb +12 -0
- data/lib/facebooker/models/user.rb +426 -0
- data/lib/facebooker/models/video.rb +9 -0
- data/lib/facebooker/models/work_info.rb +9 -0
- data/lib/facebooker/parser.rb +589 -0
- data/lib/facebooker/rails/controller.rb +304 -0
- data/lib/facebooker/rails/cucumber/world.rb +46 -0
- data/lib/facebooker/rails/cucumber.rb +28 -0
- data/lib/facebooker/rails/facebook_form_builder.rb +112 -0
- data/lib/facebooker/rails/facebook_pretty_errors.rb +22 -0
- data/lib/facebooker/rails/facebook_request_fix.rb +24 -0
- data/lib/facebooker/rails/facebook_session_handling.rb +69 -0
- data/lib/facebooker/rails/facebook_url_helper.rb +192 -0
- data/lib/facebooker/rails/facebook_url_rewriting.rb +39 -0
- data/lib/facebooker/rails/helpers/fb_connect.rb +89 -0
- data/lib/facebooker/rails/helpers.rb +762 -0
- data/lib/facebooker/rails/integration_session.rb +38 -0
- data/lib/facebooker/rails/profile_publisher_extensions.rb +42 -0
- data/lib/facebooker/rails/publisher.rb +526 -0
- data/lib/facebooker/rails/routing.rb +49 -0
- data/lib/facebooker/rails/test_helpers.rb +68 -0
- data/lib/facebooker/rails/utilities.rb +22 -0
- data/lib/facebooker/server_cache.rb +24 -0
- data/lib/facebooker/service.rb +94 -0
- data/lib/facebooker/session.rb +584 -0
- data/lib/facebooker/version.rb +9 -0
- data/lib/facebooker.rb +174 -0
- data/lib/net/http_multipart_post.rb +123 -0
- data/lib/tasks/facebooker.rake +18 -0
- data/lib/tasks/tunnel.rake +46 -0
- data/rails/init.rb +1 -0
- data/setup.rb +1585 -0
- data/templates/layout.erb +24 -0
- data/test/facebooker/adapters_test.rb +96 -0
- data/test/facebooker/admin_test.rb +102 -0
- data/test/facebooker/batch_request_test.rb +83 -0
- data/test/facebooker/data_test.rb +86 -0
- data/test/facebooker/logging_test.rb +43 -0
- data/test/facebooker/mobile_test.rb +45 -0
- data/test/facebooker/model_test.rb +123 -0
- data/test/facebooker/models/event_test.rb +15 -0
- data/test/facebooker/models/user_test.rb +295 -0
- data/test/facebooker/rails/publisher_test.rb +452 -0
- data/test/facebooker/rails_integration_test.rb +1312 -0
- data/test/facebooker/server_cache_test.rb +44 -0
- data/test/facebooker/session_test.rb +614 -0
- data/test/facebooker_test.rb +925 -0
- data/test/fixtures/multipart_post_body_with_only_parameters.txt +33 -0
- data/test/fixtures/multipart_post_body_with_single_file.txt +38 -0
- data/test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt +38 -0
- data/test/net/http_multipart_post_test.rb +52 -0
- data/test/rails_test_helper.rb +11 -0
- data/test/test_helper.rb +66 -0
- metadata +217 -0
@@ -0,0 +1,925 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/test_helper')
|
2
|
+
require 'net/http_multipart_post'
|
3
|
+
class TestFacebooker < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@api_key = "95a71599e8293s66f1f0a6f4aeab3df7"
|
7
|
+
@secret_key = "3e4du8eea435d8e205a6c9b5d095bed1"
|
8
|
+
ENV["FACEBOOK_API_KEY"] = @api_key
|
9
|
+
ENV["FACEBOOK_SECRET_KEY"] = @secret_key
|
10
|
+
@session = Facebooker::Session.create(@api_key, @secret_key)
|
11
|
+
@desktop_session = Facebooker::Session::Desktop.create(@api_key, @secret_key)
|
12
|
+
@service = Facebooker::Service.new('http://apibase.com', '/api/path', @api_key)
|
13
|
+
@desktop_session.instance_variable_set("@service", @service)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_session_must_be_created_from_api_key_and_secret_key
|
17
|
+
assert_kind_of(Facebooker::Session, @session)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_session_can_tell_you_its_login_url
|
21
|
+
assert_not_nil(@session.login_url)
|
22
|
+
assert_equal("http://www.facebook.com/login.php?api_key=#{@api_key}&v=1.0", @session.login_url)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_desktop_session_returns_auth_toke_as_part_of_login_url
|
26
|
+
@service = flexmock(@service).should_receive(:post).at_least.once.and_return(123)
|
27
|
+
assert_kind_of(Facebooker::Session::Desktop, @desktop_session)
|
28
|
+
assert_match(/auth_token=[a-z0-9A-Z]/, @desktop_session.login_url)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_service_posts_data_to_http_location
|
32
|
+
flexmock(Net::HTTP).should_receive(:post_form).and_return(example_auth_token_xml)
|
33
|
+
assert_equal("http://www.facebook.com/login.php?api_key=#{@api_key}&v=1.0&auth_token=3e4a22bb2f5ed75114b0fc9995ea85f1", @desktop_session.login_url)
|
34
|
+
end
|
35
|
+
|
36
|
+
# def test_serivce_post_file_delegates_to_post_multipart_form
|
37
|
+
# # flexmock(@service).should_receive(:url).and_return('url')
|
38
|
+
# # flexmock(Net::HTTP).expects(:post_multipart_form).with('url', {:method => 'facebook.auth.createToken'}).returns(example_auth_token_xml)
|
39
|
+
#
|
40
|
+
# res = mock(:content_type => 'text/html', :code => '200', :body => '<html><body>my blog</body></html>')
|
41
|
+
# Net::HTTP.stubs(:get_response).once.with(uri).returns res
|
42
|
+
#
|
43
|
+
# @service.post_file(:method => 'facebook.auth.createToken')
|
44
|
+
# end
|
45
|
+
|
46
|
+
def test_desktop_session_be_secured_and_activated_after_receiving_auth_token_and_logging_in
|
47
|
+
establish_session
|
48
|
+
assert_equal("5f34e11bfb97c762e439e6a5-8055", @session.instance_variable_get("@session_key"))
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_desktop_session_uses_secret_api_key_for_hashing_until_user_authenticates
|
52
|
+
assert_equal(@secret_key, @desktop_session.secret_for_method('facebook.auth.createToken'))
|
53
|
+
establish_session(@desktop_session)
|
54
|
+
assert_equal("ohairoflamao12345", @desktop_session.secret_for_method('anyNonAuthMethodName'))
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_session_can_get_current_logged_in_user_id_and_will_cache
|
58
|
+
establish_session
|
59
|
+
flexmock(Net::HTTP).should_receive(:post_form).and_return(example_get_logged_in_user_xml)
|
60
|
+
assert_equal(8055, @session.user.id)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_can_get_current_users_friends
|
64
|
+
expect_http_posts_with_responses(example_friends_xml)
|
65
|
+
assert_equal([222333, 1240079], @session.user.friends.map{|friend| friend.id})
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_can_get_current_users_friend_lists
|
69
|
+
expect_http_posts_with_responses(example_friend_lists_xml)
|
70
|
+
assert_equal([12089150545, 16361710545], @session.user.friend_lists.map{|friend_list| friend_list.flid})
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_can_get_info_for_instance_of_user
|
74
|
+
populate_user_info
|
75
|
+
@session.user.first_name = "Dave"
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_can_get_info_for_one_or_more_users
|
79
|
+
friends = populate_session_friends
|
80
|
+
friend = friends.detect{|f| f.id == 222333}
|
81
|
+
assert_equal('This field perpetuates the glorification of the ego. Also, it has a character limit.',
|
82
|
+
friend.about_me)
|
83
|
+
assert_equal('Facebook Developers', friend.affiliations.first.name)
|
84
|
+
assert_equal('Friendship', friend.meeting_for.first)
|
85
|
+
assert_equal('94303', friend.current_location.zip)
|
86
|
+
assert_equal('York', friend.hometown_location.city)
|
87
|
+
assert_equal('Harvard', friend.education_history.first.name)
|
88
|
+
assert(friend.education_history.first.concentrations.include?("Computer Science"))
|
89
|
+
assert_equal('Central York High School', friend.hs_info.hs1_name)
|
90
|
+
assert_equal('female', friend.meeting_sex.first)
|
91
|
+
assert_equal('I rule', friend.status.message)
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_can_get_specific_info_for_one_or_more_users
|
95
|
+
friends = populate_session_friends_with_limited_fields
|
96
|
+
friend = friends.detect{|f| f.id == 222333}
|
97
|
+
assert_equal('I rule', friend.status.message)
|
98
|
+
assert_equal(nil, friend.hometown_location)
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_can_handle_nil_data
|
102
|
+
friends = populate_session_friends_with_nil_data
|
103
|
+
friend = friends.detect{|f| f.id == 222333}
|
104
|
+
assert_equal(nil,friend.current_location)
|
105
|
+
assert_equal(nil,friend.pic)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_session_can_expire_on_server_and_client_handles_appropriately
|
109
|
+
expect_http_posts_with_responses(example_session_expired_error_response)
|
110
|
+
assert_raises(Facebooker::Session::SessionExpired) {
|
111
|
+
@session.user.friends
|
112
|
+
}
|
113
|
+
end
|
114
|
+
|
115
|
+
|
116
|
+
def test_can_publish_story_to_users_feed
|
117
|
+
expect_http_posts_with_responses(example_publish_story_xml)
|
118
|
+
assert_nothing_raised {
|
119
|
+
assert(@session.user.publish_story((s = Facebooker::Feed::Story.new; s.title = 'o hai'; s.body = '4srsly'; s)))
|
120
|
+
}
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
def test_can_publish_action_to_users_feed
|
125
|
+
expect_http_posts_with_responses(example_publish_action_xml)
|
126
|
+
assert_nothing_raised {
|
127
|
+
assert(@session.user.publish_action((s = Facebooker::Feed::Action.new; s.title = 'o hai'; s.body = '4srsly'; s)))
|
128
|
+
}
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_can_publish_templatized_action_to_users_feed
|
132
|
+
expect_http_posts_with_responses(example_publish_templatized_action_xml)
|
133
|
+
assert_nothing_raised {
|
134
|
+
action = Facebooker::Feed::TemplatizedAction.new
|
135
|
+
action.title_template = "{actor} did something"
|
136
|
+
assert(@session.user.publish_templatized_action(action))
|
137
|
+
}
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_can_publish_templatized_action_to_users_feed_with_params_as_string
|
141
|
+
json_data="{\"move\": \"punch\"}"
|
142
|
+
action = Facebooker::Feed::TemplatizedAction.new
|
143
|
+
action.title_template = "{actor} did something "
|
144
|
+
action.title_data=json_data
|
145
|
+
assert_equal action.to_params[:title_data],json_data
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_can_publish_templatized_action_to_users_feed_with_params_as_hash
|
149
|
+
json_data="{\"move\": \"punch\"}"
|
150
|
+
hash={:move=>"punch"}
|
151
|
+
hash.expects(:to_json).returns(json_data)
|
152
|
+
action = Facebooker::Feed::TemplatizedAction.new
|
153
|
+
action.title_template = "{actor} did something "
|
154
|
+
action.title_data=hash
|
155
|
+
assert_equal action.to_params[:title_data],json_data
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_can_deactivate_template_bundle_by_id
|
159
|
+
expect_http_posts_with_responses(example_deactivate_template_bundle_by_id_xml)
|
160
|
+
assert_equal true, @session.post('facebook.feed.deactivateTemplateBundleByID', :template_bundle_id => 123)
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_can_get_notifications_for_logged_in_user
|
164
|
+
expect_http_posts_with_responses(example_notifications_get_xml)
|
165
|
+
assert_equal("1", @session.user.notifications.messages.unread)
|
166
|
+
assert_equal("0", @session.user.notifications.pokes.unread)
|
167
|
+
assert_equal("1", @session.user.notifications.shares.unread)
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_can_send_notifications
|
171
|
+
expect_http_posts_with_responses(example_notifications_send_xml)
|
172
|
+
assert_nothing_raised {
|
173
|
+
user_ids = [123, 321]
|
174
|
+
notification_fbml = "O HAI!!!"
|
175
|
+
optional_email_fbml = "This would be in the email. If this is not passed, facebook sends no mailz!"
|
176
|
+
assert_equal('http://www.facebook.com/send_email.php?from=211031&id=52', @session.send_notification(user_ids, notification_fbml, optional_email_fbml))
|
177
|
+
}
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_can_send_emails
|
181
|
+
expect_http_posts_with_responses(example_notifications_send_email_xml)
|
182
|
+
assert_nothing_raised {
|
183
|
+
user_ids = [123, 321]
|
184
|
+
text = "Hi I am the text part of the email."
|
185
|
+
fbml = "Hi I am the fbml version of the <b>email</a>"
|
186
|
+
subject = "Somethign you should really pay attention to."
|
187
|
+
assert_equal('123,321', @session.send_email(user_ids, subject,text,fbml ))
|
188
|
+
}
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_can_find_friends_who_have_installed_app
|
192
|
+
expect_http_posts_with_responses(example_app_users_xml)
|
193
|
+
assert_equal(2, @session.user.friends_with_this_app.size)
|
194
|
+
assert_equal([222333, 1240079], @session.user.friends_with_this_app.map{|f| f.id})
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_when_marshaling_a_session_object_only_enough_data_to_stay_authenticated_is_stored
|
198
|
+
populate_session_friends
|
199
|
+
assert_equal(2, @session.user.friends.size)
|
200
|
+
reloaded_session = Marshal.load(Marshal.dump(@session))
|
201
|
+
%w(@session_key @uid @expires @secret_from_session @auth_token).each do |iv_name|
|
202
|
+
assert_not_nil(reloaded_session.instance_variable_get(iv_name))
|
203
|
+
end
|
204
|
+
assert_nil(reloaded_session.user.instance_variable_get("@friends"))
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_sessions_can_be_infinite_or_can_expire
|
208
|
+
establish_session
|
209
|
+
assert(@session.expired?, "Session with expiry time #{@session.instance_variable_get('@expires')} occurred in the past and should be expired.")
|
210
|
+
@session.instance_variable_set("@expires", 0)
|
211
|
+
assert(@session.infinite?)
|
212
|
+
assert(!@session.expired?)
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_session_can_tell_you_if_it_has_been_secured
|
216
|
+
mock = flexmock(Net::HTTP).should_receive(:post_form).and_return(example_auth_token_xml).once.ordered(:posts)
|
217
|
+
mock.should_receive(:post_form).and_return(example_get_session_xml.sub(/1173309298/, (Time.now + 60).to_i.to_s)).once.ordered(:posts)
|
218
|
+
@session.secure!
|
219
|
+
assert(@session.secured?)
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_can_get_photos_by_pids
|
223
|
+
expect_http_posts_with_responses(example_get_photo_xml)
|
224
|
+
photos = @session.get_photos([97503428461115590, 97503428461115573])
|
225
|
+
assert_equal 2, photos.size
|
226
|
+
assert_equal "Rooftop barbecues make me act funny", photos.first.caption
|
227
|
+
assert_equal 97503428461115590, photos[0].id
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_can_get_photos_by_subject_and_album
|
231
|
+
expect_http_posts_with_responses(example_get_photo_xml)
|
232
|
+
photos = @session.get_photos(nil, 22701786, 97503428432802022 )
|
233
|
+
assert_equal '97503428432802022', photos.first.aid
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_getting_photos_requires_arguments
|
237
|
+
mock_http = establish_session
|
238
|
+
assert_raise(ArgumentError) { @session.get_photos() }
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_can_get_albums_for_user
|
242
|
+
expect_http_posts_with_responses(example_user_albums_xml)
|
243
|
+
assert_equal('Summertime is Best', @session.user.albums.first.name)
|
244
|
+
assert_equal(2, @session.user.albums.size)
|
245
|
+
end
|
246
|
+
|
247
|
+
def test_can_get_albums_by_album_ids
|
248
|
+
expect_http_posts_with_responses(example_user_albums_xml)
|
249
|
+
albums = @session.get_albums([97503428432802022, 97503428432797817] )
|
250
|
+
assert_equal('Summertime is Best', albums[0].name)
|
251
|
+
assert_equal('Bonofon\'s Recital', albums[1].name)
|
252
|
+
end
|
253
|
+
|
254
|
+
def test_can_create_album
|
255
|
+
expect_http_posts_with_responses(example_new_album_xml)
|
256
|
+
assert_equal "My Empty Album", @session.user.create_album(:name => "My Empty Album", :location => "Limboland").name
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_can_upload_photo
|
260
|
+
mock_http = establish_session
|
261
|
+
mock_http.should_receive(:post_multipart_form).and_return(example_upload_photo_xml).once.ordered(:posts)
|
262
|
+
f = Net::HTTP::MultipartPostFile.new("image.jpg", "image/jpeg", "RAW DATA")
|
263
|
+
assert_equal "Under the sunset", @session.user.upload_photo(f).caption
|
264
|
+
end
|
265
|
+
|
266
|
+
def test_can_get_photo_tags
|
267
|
+
expect_http_posts_with_responses(example_photo_tags_xml)
|
268
|
+
assert_instance_of Facebooker::Tag, @session.get_tags(:pids => 97503428461115571 ).first
|
269
|
+
end
|
270
|
+
|
271
|
+
# TODO: how to test that tags were created properly? Response doesn't contain much
|
272
|
+
def test_can_tag_a_user_in_a_photo
|
273
|
+
expect_http_posts_with_responses(example_add_tag_xml)
|
274
|
+
assert !@session.add_tags(pid = 97503428461115571, x= 30.0, y = 62.5, tag_uid = 1234567890).nil?
|
275
|
+
end
|
276
|
+
|
277
|
+
def test_can_add_multiple_tags_to_photos
|
278
|
+
end
|
279
|
+
|
280
|
+
def test_can_get_coordinates_for_photo_tags
|
281
|
+
expect_http_posts_with_responses(example_photo_tags_xml)
|
282
|
+
tag = @session.get_tags([97503428461115571]).first
|
283
|
+
assert_equal ['65.4248', '16.8627'], tag.coordinates
|
284
|
+
end
|
285
|
+
|
286
|
+
def test_can_upload_video
|
287
|
+
mock_http = establish_session
|
288
|
+
mock_http.should_receive(:post_multipart_form).and_return(example_upload_video_xml).once
|
289
|
+
f = Net::HTTP::MultipartPostFile.new("party.mp4", "video/mpeg", "RAW DATA")
|
290
|
+
assert_equal "Some Epic", @session.user.upload_video(f).title
|
291
|
+
end
|
292
|
+
|
293
|
+
def test_can_get_app_profile_fbml_for_user
|
294
|
+
expect_http_posts_with_responses(example_get_fbml_xml)
|
295
|
+
assert_match(/My profile!/, @session.user.profile_fbml)
|
296
|
+
end
|
297
|
+
|
298
|
+
def test_can_set_app_profile_fbml_for_user
|
299
|
+
expect_http_posts_with_responses(example_set_fbml_xml)
|
300
|
+
assert_nothing_raised {
|
301
|
+
@session.user.profile_fbml = 'aha!'
|
302
|
+
}
|
303
|
+
end
|
304
|
+
|
305
|
+
def test_get_logged_in_user
|
306
|
+
expect_http_posts_with_responses(example_get_logged_in_user_xml)
|
307
|
+
assert_equal 1240077, @session.post('facebook.users.getLoggedInUser', :session_key => @session.session_key)
|
308
|
+
end
|
309
|
+
|
310
|
+
def test_pages_get_info
|
311
|
+
expect_http_posts_with_responses(example_pages_get_info_xml)
|
312
|
+
info = {
|
313
|
+
'page_id' => '4846711747',
|
314
|
+
'name' => 'Kronos Quartet',
|
315
|
+
'website' => 'http://www.kronosquartet.org',
|
316
|
+
'company_overview' => ""
|
317
|
+
}
|
318
|
+
assert_equal [info], @session.post('facebook.pages.getInfo', :fields => ['company_overview', 'website', 'name', 'page_id'].join(','), :page_ids => [4846711747].join(','))
|
319
|
+
end
|
320
|
+
|
321
|
+
def test_pages_is_admin_true
|
322
|
+
expect_http_posts_with_responses(example_pages_is_admin_true_xml)
|
323
|
+
assert_equal true, @session.post('facebook.pages.isAdmin', :page_id => 123)
|
324
|
+
end
|
325
|
+
|
326
|
+
def test_pages_is_admin_false
|
327
|
+
expect_http_posts_with_responses(example_pages_is_admin_false_xml)
|
328
|
+
assert_equal false, @session.post('facebook.pages.isAdmin', :page_id => 123)
|
329
|
+
end
|
330
|
+
|
331
|
+
def test_pages_is_fan_true
|
332
|
+
expect_http_posts_with_responses(example_pages_is_fan_true_xml)
|
333
|
+
assert_equal true, @session.post('facebook.pages.isFan', :page_id => 123)
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_pages_is_fan_false
|
337
|
+
expect_http_posts_with_responses(example_pages_is_fan_false_xml)
|
338
|
+
assert_equal false, @session.post('facebook.pages.isFan', :page_id => 123)
|
339
|
+
end
|
340
|
+
|
341
|
+
def test_users_set_status_true
|
342
|
+
expect_http_posts_with_responses(example_users_set_status_true_xml)
|
343
|
+
assert_equal true, @session.post('facebook.users.setStatus', :uid => 123, :status => 'message')
|
344
|
+
end
|
345
|
+
|
346
|
+
def test_users_set_status_false
|
347
|
+
expect_http_posts_with_responses(example_users_set_status_false_xml)
|
348
|
+
assert_equal false, @session.post('facebook.users.setStatus', :uid => 123, :status => 'message')
|
349
|
+
end
|
350
|
+
|
351
|
+
def test_desktop_apps_cannot_request_to_get_or_set_profile_fbml_for_any_user_other_than_logged_in_user
|
352
|
+
mock_http = establish_session(@desktop_session)
|
353
|
+
mock_http.should_receive(:post_form).and_return(example_friends_xml).once.ordered(:posts)
|
354
|
+
assert_raises(Facebooker::NonSessionUser) {
|
355
|
+
@desktop_session.user.friends.first.profile_fbml
|
356
|
+
}
|
357
|
+
assert_raises(Facebooker::NonSessionUser) {
|
358
|
+
@desktop_session.user.friends.first.profile_fbml = "O rly"
|
359
|
+
}
|
360
|
+
end
|
361
|
+
|
362
|
+
private
|
363
|
+
def populate_user_info
|
364
|
+
mock_http = establish_session
|
365
|
+
mock_http.should_receive(:post_form).and_return(example_user_info_xml).once
|
366
|
+
@session.user.populate
|
367
|
+
end
|
368
|
+
|
369
|
+
def populate_user_info_with_limited_fields
|
370
|
+
expect_http_posts_with_responses(example_limited_user_info_xml)
|
371
|
+
@session.user.populate(:affiliations, :status, :meeting_for)
|
372
|
+
end
|
373
|
+
|
374
|
+
def populate_session_friends
|
375
|
+
expect_http_posts_with_responses(example_friends_xml, example_user_info_xml)
|
376
|
+
@session.user.friends!
|
377
|
+
end
|
378
|
+
|
379
|
+
def populate_session_friends_with_limited_fields
|
380
|
+
expect_http_posts_with_responses(example_friends_xml, example_limited_user_info_xml)
|
381
|
+
@session.user.friends!(:affiliations, :status, :meeting_for)
|
382
|
+
end
|
383
|
+
|
384
|
+
def populate_session_friends_with_nil_data
|
385
|
+
expect_http_posts_with_responses(example_friends_xml, example_nil_user_info_xml)
|
386
|
+
@session.user.friends!(:name, :current_location, :pic)
|
387
|
+
end
|
388
|
+
|
389
|
+
def sample_args_to_post
|
390
|
+
{:method=>"facebook.auth.createToken", :sig=>"18b3dc4f5258a63c0ad641eebd3e3930"}
|
391
|
+
end
|
392
|
+
|
393
|
+
def example_pages_get_info_xml
|
394
|
+
<<-XML
|
395
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
396
|
+
<pages_getInfo_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
|
397
|
+
<page>
|
398
|
+
<page_id>4846711747</page_id>
|
399
|
+
<name>Kronos Quartet</name>
|
400
|
+
<website>http://www.kronosquartet.org</website>
|
401
|
+
<company_overview/>
|
402
|
+
</page>
|
403
|
+
</pages_getInfo_response>
|
404
|
+
XML
|
405
|
+
end
|
406
|
+
|
407
|
+
def example_pages_is_admin_true_xml
|
408
|
+
<<-XML
|
409
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
410
|
+
<pages_isAdmin_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1</pages_isAdmin_response>
|
411
|
+
XML
|
412
|
+
end
|
413
|
+
|
414
|
+
def example_pages_is_admin_false_xml
|
415
|
+
<<-XML
|
416
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
417
|
+
<pages_isAdmin_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">0</pages_isAdmin_response>
|
418
|
+
XML
|
419
|
+
end
|
420
|
+
|
421
|
+
def example_pages_is_fan_true_xml
|
422
|
+
<<-XML
|
423
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
424
|
+
<pages_isFan_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1</pages_isFan_response>
|
425
|
+
XML
|
426
|
+
end
|
427
|
+
|
428
|
+
def example_pages_is_fan_false_xml
|
429
|
+
<<-XML
|
430
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
431
|
+
<pages_isFan_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">0</pages_isFan_response>
|
432
|
+
XML
|
433
|
+
end
|
434
|
+
|
435
|
+
def example_users_set_status_true_xml
|
436
|
+
<<-XML
|
437
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
438
|
+
<users_setStatus_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1</users_setStatus_response>
|
439
|
+
XML
|
440
|
+
end
|
441
|
+
|
442
|
+
def example_users_set_status_false_xml
|
443
|
+
<<-XML
|
444
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
445
|
+
<users_setStatus_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">0</users_setStatus_response>
|
446
|
+
XML
|
447
|
+
end
|
448
|
+
|
449
|
+
def example_set_fbml_xml
|
450
|
+
<<-XML
|
451
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
452
|
+
<profile_setFBML_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1</profile_setFBML_response>
|
453
|
+
XML
|
454
|
+
end
|
455
|
+
|
456
|
+
def example_get_fbml_xml
|
457
|
+
<<-XML
|
458
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
459
|
+
<profile_getFBML_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
|
460
|
+
<fb:if-is-own-profile>My profile!
|
461
|
+
<fb:else> Not my profile!</fb:else>
|
462
|
+
</fb:if-is-own-profile>
|
463
|
+
</profile_getFBML_response>
|
464
|
+
XML
|
465
|
+
end
|
466
|
+
|
467
|
+
def example_notifications_send_xml
|
468
|
+
<<-XML
|
469
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
470
|
+
<notifications_send_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">http://www.facebook.com/send_email.php?from=211031&id=52</notifications_send_response>
|
471
|
+
XML
|
472
|
+
end
|
473
|
+
|
474
|
+
def example_notifications_send_email_xml
|
475
|
+
<<-XML
|
476
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
477
|
+
<notifications_sendEmail_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">123,321</notifications_sendEmail_response>
|
478
|
+
XML
|
479
|
+
end
|
480
|
+
|
481
|
+
def example_request_send_xml
|
482
|
+
<<-XML
|
483
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
484
|
+
<notifications_sendRequest_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">http://www.facebook.com/send_req.php?from=211031&id=6</notifications_sendRequest_response>
|
485
|
+
XML
|
486
|
+
end
|
487
|
+
|
488
|
+
def example_notifications_get_xml
|
489
|
+
<<-XML
|
490
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
491
|
+
<notifications_get_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
|
492
|
+
<messages>
|
493
|
+
<unread>1</unread>
|
494
|
+
<most_recent>1170644932</most_recent>
|
495
|
+
</messages>
|
496
|
+
<pokes>
|
497
|
+
<unread>0</unread>
|
498
|
+
<most_recent>0</most_recent>
|
499
|
+
</pokes>
|
500
|
+
<shares>
|
501
|
+
<unread>1</unread>
|
502
|
+
<most_recent>1170657686</most_recent>
|
503
|
+
</shares>
|
504
|
+
<friend_requests list="true">
|
505
|
+
<uid>2231342839</uid>
|
506
|
+
<uid>2231511925</uid>
|
507
|
+
<uid>2239284527</uid>
|
508
|
+
</friend_requests>
|
509
|
+
<group_invites list="true"/>
|
510
|
+
<event_invites list="true"/>
|
511
|
+
</notifications_get_response>
|
512
|
+
XML
|
513
|
+
end
|
514
|
+
|
515
|
+
def example_publish_story_xml
|
516
|
+
<<-XML
|
517
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
518
|
+
<feed_publishStoryToUser_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1</feed_publishStoryToUser_response>
|
519
|
+
XML
|
520
|
+
end
|
521
|
+
|
522
|
+
def example_publish_action_xml
|
523
|
+
<<-XML
|
524
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
525
|
+
<feed_publishActionOfUser_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1</feed_publishActionOfUser_response>
|
526
|
+
XML
|
527
|
+
end
|
528
|
+
|
529
|
+
def example_publish_templatized_action_xml
|
530
|
+
<<-XML
|
531
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
532
|
+
<feed_publishTemplatizedAction_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
|
533
|
+
<feed_publishTemplatizedAction_response_elt>1</feed_publishTemplatizedAction_response_elt>
|
534
|
+
</feed_publishTemplatizedAction_response>
|
535
|
+
XML
|
536
|
+
end
|
537
|
+
|
538
|
+
def example_deactivate_template_bundle_by_id_xml
|
539
|
+
<<-XML
|
540
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
541
|
+
<feed_deactivateTemplateBundleByID_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/">1</feed_deactivateTemplateBundleByID_response>
|
542
|
+
XML
|
543
|
+
end
|
544
|
+
|
545
|
+
def example_user_info_xml
|
546
|
+
<<-XML
|
547
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
548
|
+
<users_getInfo_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
|
549
|
+
<user>
|
550
|
+
<uid>222333</uid>
|
551
|
+
<about_me>This field perpetuates the glorification of the ego. Also, it has a character limit.</about_me>
|
552
|
+
<activities>Here: facebook, etc. There: Glee Club, a capella, teaching.</activities>
|
553
|
+
<affiliations list="true">
|
554
|
+
<affiliation>
|
555
|
+
<nid>50453093</nid>
|
556
|
+
<name>Facebook Developers</name>
|
557
|
+
<type>work</type>
|
558
|
+
<status/>
|
559
|
+
<year/>
|
560
|
+
</affiliation>
|
561
|
+
</affiliations>
|
562
|
+
<birthday>November 3</birthday>
|
563
|
+
<books>The Brothers K, GEB, Ken Wilber, Zen and the Art, Fitzgerald, The Emporer's New Mind, The Wonderful Story of Henry Sugar</books>
|
564
|
+
<current_location>
|
565
|
+
<city>Palo Alto</city>
|
566
|
+
<state>CA</state>
|
567
|
+
<country>United States</country>
|
568
|
+
<zip>94303</zip>
|
569
|
+
</current_location>
|
570
|
+
<education_history list="true">
|
571
|
+
<education_info>
|
572
|
+
<name>Harvard</name>
|
573
|
+
<year>2003</year>
|
574
|
+
<concentrations list="true">
|
575
|
+
<concentration>Applied Mathematics</concentration>
|
576
|
+
<concentration>Computer Science</concentration>
|
577
|
+
</concentrations>
|
578
|
+
<degree>Masters</degree>
|
579
|
+
</education_info>
|
580
|
+
</education_history>
|
581
|
+
<first_name>Dave</first_name>
|
582
|
+
<hometown_location>
|
583
|
+
<city>York</city>
|
584
|
+
<state>PA</state>
|
585
|
+
<country>United States</country>
|
586
|
+
<zip>0</zip>
|
587
|
+
</hometown_location>
|
588
|
+
<hs_info>
|
589
|
+
<hs1_name>Central York High School</hs1_name>
|
590
|
+
<hs2_name/>
|
591
|
+
<grad_year>1999</grad_year>
|
592
|
+
<hs1_id>21846</hs1_id>
|
593
|
+
<hs2_id>0</hs2_id>
|
594
|
+
</hs_info>
|
595
|
+
<is_app_user>1</is_app_user>
|
596
|
+
<has_added_app>1</has_added_app>
|
597
|
+
<interests>coffee, computers, the funny, architecture, code breaking,snowboarding, philosophy, soccer, talking to strangers</interests>
|
598
|
+
<last_name>Fetterman</last_name>
|
599
|
+
<meeting_for list="true">
|
600
|
+
<seeking>Friendship</seeking>
|
601
|
+
</meeting_for>
|
602
|
+
<meeting_sex list="true">
|
603
|
+
<sex>female</sex>
|
604
|
+
</meeting_sex>
|
605
|
+
<movies>Tommy Boy, Billy Madison, Fight Club, Dirty Work, Meet the Parents, My Blue Heaven, Office Space </movies>
|
606
|
+
<music>New Found Glory, Daft Punk, Weezer, The Crystal Method, Rage, the KLF, Green Day, Live, Coldplay, Panic at the Disco, Family Force 5</music>
|
607
|
+
<name>Dave Fetterman</name>
|
608
|
+
<notes_count>0</notes_count>
|
609
|
+
<pic>http://photos-055.facebook.com/ip007/profile3/1271/65/s8055_39735.jpg</pic>
|
610
|
+
<pic_big>http://photos-055.facebook.com/ip007/profile3/1271/65/n8055_39735.jpg</pic_big>
|
611
|
+
<pic_small>http://photos-055.facebook.com/ip007/profile3/1271/65/t8055_39735.jpg</pic_small>
|
612
|
+
<pic_square>http://photos-055.facebook.com/ip007/profile3/1271/65/q8055_39735.jpg</pic_square>
|
613
|
+
<political>Moderate</political>
|
614
|
+
<profile_update_time>1170414620</profile_update_time>
|
615
|
+
<quotes/>
|
616
|
+
<relationship_status>In a Relationship</relationship_status>
|
617
|
+
<religion/>
|
618
|
+
<sex>male</sex>
|
619
|
+
<significant_other_id xsi:nil="true"/>
|
620
|
+
<status>
|
621
|
+
<message>I rule</message>
|
622
|
+
<time>0</time>
|
623
|
+
</status>
|
624
|
+
<timezone>-8</timezone>
|
625
|
+
<tv>cf. Bob Trahan</tv>
|
626
|
+
<wall_count>121</wall_count>
|
627
|
+
<work_history list="true">
|
628
|
+
<work_info>
|
629
|
+
<location>
|
630
|
+
<city>Palo Alto</city>
|
631
|
+
<state>CA</state>
|
632
|
+
<country>United States</country>
|
633
|
+
</location>
|
634
|
+
<company_name>Facebook</company_name>
|
635
|
+
<position>Software Engineer</position>
|
636
|
+
<description>Tech Lead, Facebook Platform</description>
|
637
|
+
<start_date>2006-01</start_date>
|
638
|
+
<end_date/>
|
639
|
+
</work_info>
|
640
|
+
</work_history>
|
641
|
+
</user>
|
642
|
+
<user>
|
643
|
+
<uid>1240079</uid>
|
644
|
+
<about_me>I am here.</about_me>
|
645
|
+
<activities>Party.</activities>
|
646
|
+
</user>
|
647
|
+
</users_getInfo_response>
|
648
|
+
XML
|
649
|
+
end
|
650
|
+
|
651
|
+
def example_limited_user_info_xml
|
652
|
+
<<-XML
|
653
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
654
|
+
<users_getInfo_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
|
655
|
+
<user>
|
656
|
+
<uid>222333</uid>
|
657
|
+
<affiliations list="true">
|
658
|
+
<affiliation>
|
659
|
+
<nid>50453093</nid>
|
660
|
+
<name>Facebook Developers</name>
|
661
|
+
<type>work</type>
|
662
|
+
<status/>
|
663
|
+
<year/>
|
664
|
+
</affiliation>
|
665
|
+
</affiliations>
|
666
|
+
<meeting_for list="true">
|
667
|
+
<seeking>Friendship</seeking>
|
668
|
+
</meeting_for>
|
669
|
+
<status>
|
670
|
+
<message>I rule</message>
|
671
|
+
<time>0</time>
|
672
|
+
</status>
|
673
|
+
</user>
|
674
|
+
<user>
|
675
|
+
<uid>1240079</uid>
|
676
|
+
<activities>Party.</activities>
|
677
|
+
</user>
|
678
|
+
</users_getInfo_response>
|
679
|
+
XML
|
680
|
+
end
|
681
|
+
|
682
|
+
|
683
|
+
def example_nil_user_info_xml
|
684
|
+
<<-XML
|
685
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
686
|
+
<users_getInfo_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
|
687
|
+
<user>
|
688
|
+
<uid>222333</uid>
|
689
|
+
<name>Kevin Lochner</name>
|
690
|
+
<current_location xsi:nil="true"/>
|
691
|
+
<pic xsi:nil="true"/>
|
692
|
+
</user>
|
693
|
+
</users_getInfo_response>
|
694
|
+
XML
|
695
|
+
end
|
696
|
+
|
697
|
+
|
698
|
+
def example_friends_xml
|
699
|
+
<<-XML
|
700
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
701
|
+
<friends_get_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
|
702
|
+
<uid>222333</uid>
|
703
|
+
<uid>1240079</uid>
|
704
|
+
</friends_get_response>
|
705
|
+
XML
|
706
|
+
end
|
707
|
+
|
708
|
+
def example_friend_lists_xml
|
709
|
+
<<-XML
|
710
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
711
|
+
<friends_getLists_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
|
712
|
+
<friendlist>
|
713
|
+
<flid>12089150545</flid>
|
714
|
+
<name>Family</name>
|
715
|
+
</friendlist>
|
716
|
+
<friendlist>
|
717
|
+
<flid>16361710545</flid>
|
718
|
+
<name>Entrepreneuer</name>
|
719
|
+
</friendlist>
|
720
|
+
</friends_getLists_response>
|
721
|
+
XML
|
722
|
+
end
|
723
|
+
|
724
|
+
def example_get_logged_in_user_xml
|
725
|
+
<<-XML
|
726
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
727
|
+
<users_getLoggedInUser_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">1240077</users_getLoggedInUser_response>
|
728
|
+
XML
|
729
|
+
end
|
730
|
+
|
731
|
+
def example_invalid_api_key_error_response
|
732
|
+
<<-XML
|
733
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
734
|
+
<error_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
|
735
|
+
<error_code>101</error_code>
|
736
|
+
<error_msg>Invalid API key</error_msg>
|
737
|
+
<request_args list="true">
|
738
|
+
<arg>
|
739
|
+
<key>v</key>
|
740
|
+
<value>1.0</value>
|
741
|
+
</arg>
|
742
|
+
<arg>
|
743
|
+
<key>method</key>
|
744
|
+
<value>facebook.auth.createToken</value>
|
745
|
+
</arg>
|
746
|
+
<arg>
|
747
|
+
<key>sig</key>
|
748
|
+
<value>611f5f44e55f3fe17f858a8de84a4b0a</value>
|
749
|
+
</arg>
|
750
|
+
<arg>
|
751
|
+
<key>call_id</key>
|
752
|
+
<value>1186088346.82142</value>
|
753
|
+
</arg>
|
754
|
+
</request_args>
|
755
|
+
</error_response>
|
756
|
+
XML
|
757
|
+
end
|
758
|
+
|
759
|
+
def example_session_expired_error_response
|
760
|
+
<<-XML
|
761
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
762
|
+
<error_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
|
763
|
+
<error_code>102</error_code>
|
764
|
+
<error_msg>Session Expired</error_msg>
|
765
|
+
<request_args list="true">
|
766
|
+
<arg>
|
767
|
+
<key>v</key>
|
768
|
+
<value>1.0</value>
|
769
|
+
</arg>
|
770
|
+
<arg>
|
771
|
+
<key>method</key>
|
772
|
+
<value>facebook.auth.createToken</value>
|
773
|
+
</arg>
|
774
|
+
<arg>
|
775
|
+
<key>sig</key>
|
776
|
+
<value>611f5f44e55f3fe17f858a8de84a4b0a</value>
|
777
|
+
</arg>
|
778
|
+
<arg>
|
779
|
+
<key>call_id</key>
|
780
|
+
<value>1186088346.82142</value>
|
781
|
+
</arg>
|
782
|
+
</request_args>
|
783
|
+
</error_response>
|
784
|
+
XML
|
785
|
+
end
|
786
|
+
|
787
|
+
def example_app_users_xml
|
788
|
+
<<-XML
|
789
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
790
|
+
<friends_getAppUsers_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
|
791
|
+
<uid>222333</uid>
|
792
|
+
<uid>1240079</uid>
|
793
|
+
</friends_getAppUsers_response>
|
794
|
+
XML
|
795
|
+
end
|
796
|
+
|
797
|
+
def example_user_albums_xml
|
798
|
+
<<-XML
|
799
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
800
|
+
<photos_getAlbums_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
|
801
|
+
<album>
|
802
|
+
<aid>97503428432802022</aid>
|
803
|
+
<cover_pid>97503428461115574</cover_pid>
|
804
|
+
<owner>22701786</owner>
|
805
|
+
<name>Summertime is Best</name>
|
806
|
+
<created>1184120648</created>
|
807
|
+
<modified>1185465771</modified>
|
808
|
+
<description>Happenings on or around Summer '07</description>
|
809
|
+
<location>Brooklyn, New York</location>
|
810
|
+
<link>http://www.facebook.com/album.php?aid=2011366&id=22701786</link>
|
811
|
+
<size>49</size>
|
812
|
+
</album>
|
813
|
+
<album>
|
814
|
+
<aid>97503428432797817</aid>
|
815
|
+
<cover_pid>97503428460977993</cover_pid>
|
816
|
+
<owner>22701786</owner>
|
817
|
+
<name>Bonofon's Recital</name>
|
818
|
+
<created>1165356279</created>
|
819
|
+
<modified>1165382364</modified>
|
820
|
+
<description>The whole Ewing fam flies out to flatland to watch the Bonofon's senior recital. That boy sure can tinkle them ivories.</description>
|
821
|
+
<location>Grinnell College, Grinnell Iowa</location>
|
822
|
+
<link>http://www.facebook.com/album.php?aid=2007161&id=22701786</link>
|
823
|
+
<size>14</size>
|
824
|
+
</album>
|
825
|
+
</photos_getAlbums_response>
|
826
|
+
XML
|
827
|
+
end
|
828
|
+
|
829
|
+
def example_upload_photo_xml
|
830
|
+
<<-XML
|
831
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
832
|
+
<photos_upload_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
|
833
|
+
<pid>940915697041656</pid>
|
834
|
+
<aid>940915667462717</aid>
|
835
|
+
<owner>219074</owner>
|
836
|
+
<src>http://ip002.facebook.com/v67/161/72/219074/s219074_31637752_5455.jpg</src>
|
837
|
+
<src_big>http://ip002.facebook.com/v67/161/72/219074/n219074_31637752_5455.jpg</src_big>
|
838
|
+
<src_small>http://ip002.facebook.com/v67/161/72/219074/t219074_31637752_5455.jpg</src_small>
|
839
|
+
<link>http://www.facebook.com/photo.php?pid=31637752&id=219074</link>
|
840
|
+
<caption>Under the sunset</caption>
|
841
|
+
</photos_upload_response>
|
842
|
+
XML
|
843
|
+
end
|
844
|
+
|
845
|
+
def example_new_album_xml
|
846
|
+
<<-XML
|
847
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
848
|
+
<photos_createAlbum_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
|
849
|
+
<aid>34595963571485</aid>
|
850
|
+
<cover_pid>0</cover_pid>
|
851
|
+
<owner>8055</owner>
|
852
|
+
<name>My Empty Album</name>
|
853
|
+
<created>1132553109</created>
|
854
|
+
<modified>1132553363</modified>
|
855
|
+
<description>No I will not make out with you</description>
|
856
|
+
<location>York, PA</location>
|
857
|
+
<link>http://www.facebook.com/album.php?aid=2002205&id=8055</link>
|
858
|
+
<size>0</size>
|
859
|
+
</photos_createAlbum_response>
|
860
|
+
XML
|
861
|
+
end
|
862
|
+
|
863
|
+
def example_photo_tags_xml
|
864
|
+
<<-XML
|
865
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
866
|
+
<photos_getTags_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
|
867
|
+
<photo_tag>
|
868
|
+
<pid>97503428461115571</pid>
|
869
|
+
<subject>570070524</subject>
|
870
|
+
<xcoord>65.4248</xcoord>
|
871
|
+
<ycoord>16.8627</ycoord>
|
872
|
+
</photo_tag>
|
873
|
+
</photos_getTags_response>
|
874
|
+
XML
|
875
|
+
end
|
876
|
+
|
877
|
+
def example_add_tag_xml
|
878
|
+
<<-XML
|
879
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
880
|
+
<photos_addTag_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">1</photos_addTag_response>
|
881
|
+
XML
|
882
|
+
end
|
883
|
+
|
884
|
+
def example_get_photo_xml
|
885
|
+
<<-XML
|
886
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
887
|
+
<photos_get_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd" list="true">
|
888
|
+
<photo>
|
889
|
+
<pid>97503428461115590</pid>
|
890
|
+
<aid>97503428432802022</aid>
|
891
|
+
<owner>22701786</owner>
|
892
|
+
<src>http://photos-c.ak.facebook.com/photos-ak-sf2p/v77/74/112/22701786/s22701786_30324934_7816.jpg</src>
|
893
|
+
<src_big>http://photos-c.ak.facebook.com/photos-ak-sf2p/v77/74/112/22701786/n22701786_30324934_7816.jpg</src_big>
|
894
|
+
<src_small>http://photos-c.ak.facebook.com/photos-ak-sf2p/v77/74/112/22701786/t22701786_30324934_7816.jpg</src_small>
|
895
|
+
<link>http://www.facebook.com/photo.php?pid=30324934&id=22701786</link>
|
896
|
+
<caption>Rooftop barbecues make me act funny</caption>
|
897
|
+
<created>1184120987</created>
|
898
|
+
</photo>
|
899
|
+
<photo>
|
900
|
+
<pid>97503428461115573</pid>
|
901
|
+
<aid>97503428432802022</aid>
|
902
|
+
<owner>22701786</owner>
|
903
|
+
<src>http://photos-b.ak.facebook.com/photos-ak-sf2p/v77/74/112/22701786/s22701786_30324917_4555.jpg</src>
|
904
|
+
<src_big>http://photos-b.ak.facebook.com/photos-ak-sf2p/v77/74/112/22701786/n22701786_30324917_4555.jpg</src_big>
|
905
|
+
<src_small>http://photos-b.ak.facebook.com/photos-ak-sf2p/v77/74/112/22701786/t22701786_30324917_4555.jpg</src_small>
|
906
|
+
<link>http://www.facebook.com/photo.php?pid=30324917&id=22701786</link>
|
907
|
+
<caption/>
|
908
|
+
<created>1184120654</created>
|
909
|
+
</photo>
|
910
|
+
</photos_get_response>
|
911
|
+
XML
|
912
|
+
end
|
913
|
+
|
914
|
+
def example_upload_video_xml
|
915
|
+
<<-XML
|
916
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
917
|
+
<video_upload_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://api.facebook.com/1.0/ http://api.facebook.com/1.0/facebook.xsd">
|
918
|
+
<vid>15943367753</vid>
|
919
|
+
<title>Some Epic</title>
|
920
|
+
<description>Check it out</description>
|
921
|
+
<link>http://www.facebook.com/video/video.php?v=15943367753</link>
|
922
|
+
</video_upload_response>
|
923
|
+
XML
|
924
|
+
end
|
925
|
+
end
|