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