jet-facebooker 1.0.64

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.
Files changed (156) hide show
  1. data/.autotest +15 -0
  2. data/CHANGELOG.rdoc +24 -0
  3. data/COPYING.rdoc +19 -0
  4. data/Manifest.txt +152 -0
  5. data/README.rdoc +119 -0
  6. data/Rakefile +94 -0
  7. data/TODO.rdoc +4 -0
  8. data/examples/desktop_login.rb +14 -0
  9. data/facebooker.gemspec +42 -0
  10. data/generators/facebook/facebook_generator.rb +14 -0
  11. data/generators/facebook/templates/config/facebooker.yml +49 -0
  12. data/generators/facebook/templates/public/javascripts/facebooker.js +332 -0
  13. data/generators/facebook_controller/USAGE +33 -0
  14. data/generators/facebook_controller/facebook_controller_generator.rb +40 -0
  15. data/generators/facebook_controller/templates/controller.rb +7 -0
  16. data/generators/facebook_controller/templates/functional_test.rb +11 -0
  17. data/generators/facebook_controller/templates/helper.rb +2 -0
  18. data/generators/facebook_controller/templates/view.fbml.erb +2 -0
  19. data/generators/facebook_controller/templates/view.html.erb +2 -0
  20. data/generators/facebook_publisher/facebook_publisher_generator.rb +14 -0
  21. data/generators/facebook_publisher/templates/create_facebook_templates.rb +15 -0
  22. data/generators/facebook_publisher/templates/publisher.rb +3 -0
  23. data/generators/facebook_scaffold/USAGE +27 -0
  24. data/generators/facebook_scaffold/facebook_scaffold_generator.rb +118 -0
  25. data/generators/facebook_scaffold/templates/controller.rb +93 -0
  26. data/generators/facebook_scaffold/templates/facebook_style.css +2579 -0
  27. data/generators/facebook_scaffold/templates/functional_test.rb +89 -0
  28. data/generators/facebook_scaffold/templates/helper.rb +2 -0
  29. data/generators/facebook_scaffold/templates/layout.fbml.erb +6 -0
  30. data/generators/facebook_scaffold/templates/layout.html.erb +17 -0
  31. data/generators/facebook_scaffold/templates/style.css +74 -0
  32. data/generators/facebook_scaffold/templates/view_edit.fbml.erb +13 -0
  33. data/generators/facebook_scaffold/templates/view_edit.html.erb +18 -0
  34. data/generators/facebook_scaffold/templates/view_index.fbml.erb +24 -0
  35. data/generators/facebook_scaffold/templates/view_index.html.erb +24 -0
  36. data/generators/facebook_scaffold/templates/view_new.fbml.erb +12 -0
  37. data/generators/facebook_scaffold/templates/view_new.html.erb +17 -0
  38. data/generators/facebook_scaffold/templates/view_show.fbml.erb +10 -0
  39. data/generators/facebook_scaffold/templates/view_show.html.erb +10 -0
  40. data/generators/publisher/publisher_generator.rb +14 -0
  41. data/generators/xd_receiver/templates/xd_receiver.html +10 -0
  42. data/generators/xd_receiver/templates/xd_receiver_ssl.html +10 -0
  43. data/generators/xd_receiver/xd_receiver_generator.rb +10 -0
  44. data/init.rb +26 -0
  45. data/install.rb +12 -0
  46. data/lib/facebooker.rb +261 -0
  47. data/lib/facebooker/adapters/adapter_base.rb +91 -0
  48. data/lib/facebooker/adapters/bebo_adapter.rb +77 -0
  49. data/lib/facebooker/adapters/facebook_adapter.rb +60 -0
  50. data/lib/facebooker/admin.rb +42 -0
  51. data/lib/facebooker/application.rb +37 -0
  52. data/lib/facebooker/attachment.rb +51 -0
  53. data/lib/facebooker/batch_request.rb +45 -0
  54. data/lib/facebooker/data.rb +57 -0
  55. data/lib/facebooker/feed.rb +78 -0
  56. data/lib/facebooker/logging.rb +44 -0
  57. data/lib/facebooker/mobile.rb +20 -0
  58. data/lib/facebooker/mock/service.rb +50 -0
  59. data/lib/facebooker/mock/session.rb +18 -0
  60. data/lib/facebooker/model.rb +139 -0
  61. data/lib/facebooker/models/affiliation.rb +10 -0
  62. data/lib/facebooker/models/album.rb +11 -0
  63. data/lib/facebooker/models/applicationproperties.rb +39 -0
  64. data/lib/facebooker/models/applicationrestrictions.rb +10 -0
  65. data/lib/facebooker/models/comment.rb +9 -0
  66. data/lib/facebooker/models/cookie.rb +10 -0
  67. data/lib/facebooker/models/education_info.rb +11 -0
  68. data/lib/facebooker/models/event.rb +28 -0
  69. data/lib/facebooker/models/family_relative_info.rb +7 -0
  70. data/lib/facebooker/models/friend_list.rb +16 -0
  71. data/lib/facebooker/models/group.rb +36 -0
  72. data/lib/facebooker/models/info_item.rb +10 -0
  73. data/lib/facebooker/models/info_section.rb +10 -0
  74. data/lib/facebooker/models/location.rb +8 -0
  75. data/lib/facebooker/models/message_thread.rb +89 -0
  76. data/lib/facebooker/models/notifications.rb +17 -0
  77. data/lib/facebooker/models/page.rb +46 -0
  78. data/lib/facebooker/models/photo.rb +19 -0
  79. data/lib/facebooker/models/tag.rb +12 -0
  80. data/lib/facebooker/models/user.rb +722 -0
  81. data/lib/facebooker/models/video.rb +9 -0
  82. data/lib/facebooker/models/work_info.rb +10 -0
  83. data/lib/facebooker/parser.rb +951 -0
  84. data/lib/facebooker/rails/backwards_compatible_param_checks.rb +31 -0
  85. data/lib/facebooker/rails/controller.rb +353 -0
  86. data/lib/facebooker/rails/cucumber.rb +28 -0
  87. data/lib/facebooker/rails/cucumber/world.rb +40 -0
  88. data/lib/facebooker/rails/extensions/action_controller.rb +48 -0
  89. data/lib/facebooker/rails/extensions/rack_setup.rb +16 -0
  90. data/lib/facebooker/rails/extensions/routing.rb +15 -0
  91. data/lib/facebooker/rails/facebook_form_builder.rb +141 -0
  92. data/lib/facebooker/rails/facebook_pretty_errors.rb +22 -0
  93. data/lib/facebooker/rails/facebook_request_fix.rb +28 -0
  94. data/lib/facebooker/rails/facebook_request_fix_2-3.rb +31 -0
  95. data/lib/facebooker/rails/facebook_session_handling.rb +68 -0
  96. data/lib/facebooker/rails/facebook_url_helper.rb +192 -0
  97. data/lib/facebooker/rails/facebook_url_rewriting.rb +61 -0
  98. data/lib/facebooker/rails/helpers.rb +835 -0
  99. data/lib/facebooker/rails/helpers/fb_connect.rb +161 -0
  100. data/lib/facebooker/rails/helpers/stream_publish.rb +22 -0
  101. data/lib/facebooker/rails/integration_session.rb +38 -0
  102. data/lib/facebooker/rails/profile_publisher_extensions.rb +42 -0
  103. data/lib/facebooker/rails/publisher.rb +600 -0
  104. data/lib/facebooker/rails/routing.rb +49 -0
  105. data/lib/facebooker/rails/test_helpers.rb +68 -0
  106. data/lib/facebooker/rails/utilities.rb +22 -0
  107. data/lib/facebooker/server_cache.rb +24 -0
  108. data/lib/facebooker/service.rb +103 -0
  109. data/lib/facebooker/service/base_service.rb +19 -0
  110. data/lib/facebooker/service/curl_service.rb +44 -0
  111. data/lib/facebooker/service/net_http_service.rb +12 -0
  112. data/lib/facebooker/service/typhoeus_multi_service.rb +27 -0
  113. data/lib/facebooker/service/typhoeus_service.rb +17 -0
  114. data/lib/facebooker/session.rb +771 -0
  115. data/lib/facebooker/stream_post.rb +19 -0
  116. data/lib/facebooker/version.rb +9 -0
  117. data/lib/net/http_multipart_post.rb +123 -0
  118. data/lib/rack/facebook.rb +89 -0
  119. data/lib/rack/facebook_session.rb +21 -0
  120. data/lib/tasks/facebooker.rake +19 -0
  121. data/lib/tasks/facebooker.rb +2 -0
  122. data/lib/tasks/tunnel.rake +46 -0
  123. data/rails/init.rb +1 -0
  124. data/setup.rb +1585 -0
  125. data/templates/layout.erb +24 -0
  126. data/test/facebooker/adapters_test.rb +191 -0
  127. data/test/facebooker/admin_test.rb +102 -0
  128. data/test/facebooker/application_test.rb +110 -0
  129. data/test/facebooker/attachment_test.rb +72 -0
  130. data/test/facebooker/batch_request_test.rb +83 -0
  131. data/test/facebooker/data_test.rb +86 -0
  132. data/test/facebooker/logging_test.rb +43 -0
  133. data/test/facebooker/mobile_test.rb +45 -0
  134. data/test/facebooker/model_test.rb +133 -0
  135. data/test/facebooker/models/event_test.rb +15 -0
  136. data/test/facebooker/models/page_test.rb +56 -0
  137. data/test/facebooker/models/photo_test.rb +16 -0
  138. data/test/facebooker/models/user_test.rb +1074 -0
  139. data/test/facebooker/rails/facebook_request_fix_2-3_test.rb +25 -0
  140. data/test/facebooker/rails/facebook_url_rewriting_test.rb +76 -0
  141. data/test/facebooker/rails/integration_session_test.rb +13 -0
  142. data/test/facebooker/rails/publisher_test.rb +532 -0
  143. data/test/facebooker/rails_integration_test.rb +1543 -0
  144. data/test/facebooker/server_cache_test.rb +44 -0
  145. data/test/facebooker/service_test.rb +58 -0
  146. data/test/facebooker/session_test.rb +883 -0
  147. data/test/facebooker_test.rb +1175 -0
  148. data/test/fixtures/multipart_post_body_with_only_parameters.txt +33 -0
  149. data/test/fixtures/multipart_post_body_with_single_file.txt +38 -0
  150. data/test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt +38 -0
  151. data/test/net/http_multipart_post_test.rb +52 -0
  152. data/test/rack/facebook_session_test.rb +34 -0
  153. data/test/rack/facebook_test.rb +73 -0
  154. data/test/rails_test_helper.rb +36 -0
  155. data/test/test_helper.rb +74 -0
  156. metadata +289 -0
@@ -0,0 +1,1175 @@
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_comments_by_xid
250
+ expect_http_posts_with_responses(example_comments_xml)
251
+ comments = @session.get_comments('pete_comments')
252
+ assert_equal('Hola', comments[0].text)
253
+ assert_equal(2, comments.size)
254
+ end
255
+
256
+ def test_can_get_albums_for_user
257
+ expect_http_posts_with_responses(example_user_albums_xml)
258
+ assert_equal('Summertime is Best', @session.user.albums.first.name)
259
+ assert_equal(2, @session.user.albums.size)
260
+ end
261
+
262
+ def test_can_get_albums_by_album_ids
263
+ expect_http_posts_with_responses(example_user_albums_xml)
264
+ albums = @session.get_albums([97503428432802022, 97503428432797817] )
265
+ assert_equal('Summertime is Best', albums[0].name)
266
+ assert_equal('Bonofon\'s Recital', albums[1].name)
267
+ end
268
+
269
+ def test_can_get_stream
270
+ expect_http_posts_with_responses(example_user_stream_xml)
271
+ stream = @session.get_stream(100000637452380)
272
+ assert stream[:albums].empty?
273
+ assert_equal('The bbc home page', stream[:posts].first['message'])
274
+ end
275
+
276
+ def test_can_create_album
277
+ expect_http_posts_with_responses(example_new_album_xml)
278
+ assert_equal "My Empty Album", @session.user.create_album(:name => "My Empty Album", :location => "Limboland").name
279
+ end
280
+
281
+ def test_can_upload_photo
282
+ mock_http = establish_session
283
+ mock_http.should_receive(:post_multipart_form).and_return(example_upload_photo_xml).once.ordered(:posts)
284
+ f = Net::HTTP::MultipartPostFile.new("image.jpg", "image/jpeg", "RAW DATA")
285
+ assert_equal "Under the sunset", @session.user.upload_photo(f).caption
286
+ end
287
+
288
+ def test_can_get_photo_tags
289
+ expect_http_posts_with_responses(example_photo_tags_xml)
290
+ assert_instance_of Facebooker::Tag, @session.get_tags(:pids => 97503428461115571 ).first
291
+ end
292
+
293
+ # TODO: how to test that tags were created properly? Response doesn't contain much
294
+ def test_can_tag_a_user_in_a_photo
295
+ expect_http_posts_with_responses(example_add_tag_xml)
296
+ assert !@session.add_tags(pid = 97503428461115571, x= 30.0, y = 62.5, tag_uid = 1234567890).nil?
297
+ end
298
+
299
+ def test_can_add_multiple_tags_to_photos
300
+ end
301
+
302
+ def test_can_get_coordinates_for_photo_tags
303
+ expect_http_posts_with_responses(example_photo_tags_xml)
304
+ tag = @session.get_tags([97503428461115571]).first
305
+ assert_equal ['65.4248', '16.8627'], tag.coordinates
306
+ end
307
+
308
+ def test_can_upload_video
309
+ mock_http = establish_session
310
+ mock_http.should_receive(:post_multipart_form).and_return(example_upload_video_xml).once
311
+ f = Net::HTTP::MultipartPostFile.new("party.mp4", "video/mpeg", "RAW DATA")
312
+ assert_equal "Some Epic", @session.user.upload_video(f).title
313
+ end
314
+
315
+ def test_can_get_app_profile_fbml_for_user
316
+ expect_http_posts_with_responses(example_get_fbml_xml)
317
+ assert_match(/My profile!/, @session.user.profile_fbml)
318
+ end
319
+
320
+ def test_can_set_app_profile_fbml_for_user
321
+ expect_http_posts_with_responses(example_set_fbml_xml)
322
+ assert_nothing_raised {
323
+ @session.user.profile_fbml = 'aha!'
324
+ }
325
+ end
326
+
327
+ def test_get_logged_in_user
328
+ expect_http_posts_with_responses(example_get_logged_in_user_xml)
329
+ assert_equal 1240077, @session.post('facebook.users.getLoggedInUser', :session_key => @session.session_key)
330
+ end
331
+
332
+ def test_pages_get_info
333
+ expect_http_posts_with_responses(example_pages_get_info_xml)
334
+ info = {
335
+ 'page_id' => '4846711747',
336
+ 'name' => 'Kronos Quartet',
337
+ 'website' => 'http://www.kronosquartet.org',
338
+ 'company_overview' => ""
339
+ }
340
+ assert_equal [info], @session.post('facebook.pages.getInfo', :fields => ['company_overview', 'website', 'name', 'page_id'].join(','), :page_ids => [4846711747].join(','))
341
+ end
342
+
343
+ def test_pages_is_admin_true
344
+ expect_http_posts_with_responses(example_pages_is_admin_true_xml)
345
+ assert_equal true, @session.post('facebook.pages.isAdmin', :page_id => 123)
346
+ end
347
+
348
+ def test_pages_is_admin_false
349
+ expect_http_posts_with_responses(example_pages_is_admin_false_xml)
350
+ assert_equal false, @session.post('facebook.pages.isAdmin', :page_id => 123)
351
+ end
352
+
353
+ def test_pages_is_fan_true
354
+ expect_http_posts_with_responses(example_pages_is_fan_true_xml)
355
+ assert_equal true, @session.post('facebook.pages.isFan', :page_id => 123)
356
+ end
357
+
358
+ def test_pages_is_fan_false
359
+ expect_http_posts_with_responses(example_pages_is_fan_false_xml)
360
+ assert_equal false, @session.post('facebook.pages.isFan', :page_id => 123)
361
+ end
362
+
363
+ def test_users_set_status_true
364
+ expect_http_posts_with_responses(example_users_set_status_true_xml)
365
+ assert_equal true, @session.post('facebook.users.setStatus', :uid => 123, :status => 'message')
366
+ end
367
+
368
+ def test_users_set_status_false
369
+ expect_http_posts_with_responses(example_users_set_status_false_xml)
370
+ assert_equal false, @session.post('facebook.users.setStatus', :uid => 123, :status => 'message')
371
+ end
372
+
373
+ def test_desktop_apps_cannot_request_to_get_or_set_profile_fbml_for_any_user_other_than_logged_in_user
374
+ mock_http = establish_session(@desktop_session)
375
+ mock_http.should_receive(:post_form).and_return(example_friends_xml).once.ordered(:posts)
376
+ assert_raises(Facebooker::NonSessionUser) {
377
+ @desktop_session.user.friends.first.profile_fbml
378
+ }
379
+ assert_raises(Facebooker::NonSessionUser) {
380
+ @desktop_session.user.friends.first.profile_fbml = "O rly"
381
+ }
382
+ end
383
+
384
+ def test_revoke_authorization_true
385
+ expect_http_posts_with_responses(example_revoke_authorization_true)
386
+ assert_equal true, @session.post('facebook.auth.revokeAuthorization', :uid => 123)
387
+ end
388
+
389
+ def test_revoke_authorization_false
390
+ expect_http_posts_with_responses(example_revoke_authorization_false)
391
+ assert_equal false, @session.post('facebook.auth.revokeAuthorization', :uid => 123)
392
+ end
393
+
394
+
395
+
396
+ def test_remove_comment_true
397
+ expect_http_posts_with_responses(example_remove_comment_true)
398
+ assert_equal true, @session.remove_comment('pete_comments',123)
399
+ end
400
+
401
+ def test_remove_comment_false
402
+ expect_http_posts_with_responses(example_remove_comment_false)
403
+ assert_equal false, @session.remove_comment('pete_comments',123)
404
+ end
405
+
406
+
407
+
408
+ private
409
+ def populate_user_info
410
+ mock_http = establish_session
411
+ mock_http.should_receive(:post_form).and_return(example_user_info_xml).once
412
+ @session.user.populate
413
+ end
414
+
415
+ def populate_user_info_with_limited_fields
416
+ expect_http_posts_with_responses(example_limited_user_info_xml)
417
+ @session.user.populate(:affiliations, :status, :meeting_for)
418
+ end
419
+
420
+ def populate_session_friends
421
+ expect_http_posts_with_responses(example_friends_xml, example_user_info_xml)
422
+ @session.user.friends!
423
+ end
424
+
425
+ def populate_session_friends_with_limited_fields
426
+ expect_http_posts_with_responses(example_friends_xml, example_limited_user_info_xml)
427
+ @session.user.friends!(:affiliations, :status, :meeting_for)
428
+ end
429
+
430
+ def populate_session_friends_with_nil_data
431
+ expect_http_posts_with_responses(example_friends_xml, example_nil_user_info_xml)
432
+ @session.user.friends!(:name, :current_location, :pic)
433
+ end
434
+
435
+ def sample_args_to_post
436
+ {:method=>"facebook.auth.createToken", :sig=>"18b3dc4f5258a63c0ad641eebd3e3930"}
437
+ end
438
+
439
+ def example_pages_get_info_xml
440
+ <<-XML
441
+ <?xml version="1.0" encoding="UTF-8"?>
442
+ <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">
443
+ <page>
444
+ <page_id>4846711747</page_id>
445
+ <name>Kronos Quartet</name>
446
+ <website>http://www.kronosquartet.org</website>
447
+ <company_overview/>
448
+ </page>
449
+ </pages_getInfo_response>
450
+ XML
451
+ end
452
+
453
+ def example_pages_is_admin_true_xml
454
+ <<-XML
455
+ <?xml version="1.0" encoding="UTF-8"?>
456
+ <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>
457
+ XML
458
+ end
459
+
460
+ def example_pages_is_admin_false_xml
461
+ <<-XML
462
+ <?xml version="1.0" encoding="UTF-8"?>
463
+ <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>
464
+ XML
465
+ end
466
+
467
+ def example_pages_is_fan_true_xml
468
+ <<-XML
469
+ <?xml version="1.0" encoding="UTF-8"?>
470
+ <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>
471
+ XML
472
+ end
473
+
474
+ def example_pages_is_fan_false_xml
475
+ <<-XML
476
+ <?xml version="1.0" encoding="UTF-8"?>
477
+ <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>
478
+ XML
479
+ end
480
+
481
+ def example_users_set_status_true_xml
482
+ <<-XML
483
+ <?xml version="1.0" encoding="UTF-8"?>
484
+ <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>
485
+ XML
486
+ end
487
+
488
+ def example_users_set_status_false_xml
489
+ <<-XML
490
+ <?xml version="1.0" encoding="UTF-8"?>
491
+ <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>
492
+ XML
493
+ end
494
+
495
+ def example_set_fbml_xml
496
+ <<-XML
497
+ <?xml version="1.0" encoding="UTF-8"?>
498
+ <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>
499
+ XML
500
+ end
501
+
502
+ def example_get_fbml_xml
503
+ <<-XML
504
+ <?xml version="1.0" encoding="UTF-8"?>
505
+ <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">
506
+ &lt;fb:if-is-own-profile&gt;My profile!
507
+ &lt;fb:else&gt; Not my profile!&lt;/fb:else&gt;
508
+ &lt;/fb:if-is-own-profile&gt;
509
+ </profile_getFBML_response>
510
+ XML
511
+ end
512
+
513
+ def example_notifications_send_xml
514
+ <<-XML
515
+ <?xml version="1.0" encoding="UTF-8"?>
516
+ <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&amp;id=52</notifications_send_response>
517
+ XML
518
+ end
519
+
520
+ def example_notifications_send_email_xml
521
+ <<-XML
522
+ <?xml version="1.0" encoding="UTF-8"?>
523
+ <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>
524
+ XML
525
+ end
526
+
527
+ def example_request_send_xml
528
+ <<-XML
529
+ <?xml version="1.0" encoding="UTF-8"?>
530
+ <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>
531
+ XML
532
+ end
533
+
534
+ def example_notifications_get_xml
535
+ <<-XML
536
+ <?xml version="1.0" encoding="UTF-8"?>
537
+ <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">
538
+ <messages>
539
+ <unread>1</unread>
540
+ <most_recent>1170644932</most_recent>
541
+ </messages>
542
+ <pokes>
543
+ <unread>0</unread>
544
+ <most_recent>0</most_recent>
545
+ </pokes>
546
+ <shares>
547
+ <unread>1</unread>
548
+ <most_recent>1170657686</most_recent>
549
+ </shares>
550
+ <friend_requests list="true">
551
+ <uid>2231342839</uid>
552
+ <uid>2231511925</uid>
553
+ <uid>2239284527</uid>
554
+ </friend_requests>
555
+ <group_invites list="true"/>
556
+ <event_invites list="true"/>
557
+ </notifications_get_response>
558
+ XML
559
+ end
560
+
561
+ def example_publish_story_xml
562
+ <<-XML
563
+ <?xml version="1.0" encoding="UTF-8"?>
564
+ <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>
565
+ XML
566
+ end
567
+
568
+ def example_publish_action_xml
569
+ <<-XML
570
+ <?xml version="1.0" encoding="UTF-8"?>
571
+ <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>
572
+ XML
573
+ end
574
+
575
+ def example_publish_templatized_action_xml
576
+ <<-XML
577
+ <?xml version="1.0" encoding="UTF-8"?>
578
+ <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">
579
+ <feed_publishTemplatizedAction_response_elt>1</feed_publishTemplatizedAction_response_elt>
580
+ </feed_publishTemplatizedAction_response>
581
+ XML
582
+ end
583
+
584
+ def example_deactivate_template_bundle_by_id_xml
585
+ <<-XML
586
+ <?xml version="1.0" encoding="UTF-8"?>
587
+ <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>
588
+ XML
589
+ end
590
+
591
+ def example_user_info_xml
592
+ <<-XML
593
+ <?xml version="1.0" encoding="UTF-8"?>
594
+ <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">
595
+ <user>
596
+ <uid>222333</uid>
597
+ <about_me>This field perpetuates the glorification of the ego. Also, it has a character limit.</about_me>
598
+ <activities>Here: facebook, etc. There: Glee Club, a capella, teaching.</activities>
599
+ <affiliations list="true">
600
+ <affiliation>
601
+ <nid>50453093</nid>
602
+ <name>Facebook Developers</name>
603
+ <type>work</type>
604
+ <status/>
605
+ <year/>
606
+ </affiliation>
607
+ </affiliations>
608
+ <birthday>November 3</birthday>
609
+ <books>The Brothers K, GEB, Ken Wilber, Zen and the Art, Fitzgerald, The Emporer's New Mind, The Wonderful Story of Henry Sugar</books>
610
+ <current_location>
611
+ <city>Palo Alto</city>
612
+ <state>CA</state>
613
+ <country>United States</country>
614
+ <zip>94303</zip>
615
+ </current_location>
616
+ <education_history list="true">
617
+ <education_info>
618
+ <name>Harvard</name>
619
+ <year>2003</year>
620
+ <concentrations list="true">
621
+ <concentration>Applied Mathematics</concentration>
622
+ <concentration>Computer Science</concentration>
623
+ </concentrations>
624
+ <degree>Masters</degree>
625
+ </education_info>
626
+ </education_history>
627
+ <first_name>Dave</first_name>
628
+ <hometown_location>
629
+ <city>York</city>
630
+ <state>PA</state>
631
+ <country>United States</country>
632
+ <zip>0</zip>
633
+ </hometown_location>
634
+ <hs_info>
635
+ <hs1_name>Central York High School</hs1_name>
636
+ <hs2_name/>
637
+ <grad_year>1999</grad_year>
638
+ <hs1_id>21846</hs1_id>
639
+ <hs2_id>0</hs2_id>
640
+ </hs_info>
641
+ <is_app_user>1</is_app_user>
642
+ <has_added_app>1</has_added_app>
643
+ <interests>coffee, computers, the funny, architecture, code breaking,snowboarding, philosophy, soccer, talking to strangers</interests>
644
+ <last_name>Fetterman</last_name>
645
+ <meeting_for list="true">
646
+ <seeking>Friendship</seeking>
647
+ </meeting_for>
648
+ <meeting_sex list="true">
649
+ <sex>female</sex>
650
+ </meeting_sex>
651
+ <movies>Tommy Boy, Billy Madison, Fight Club, Dirty Work, Meet the Parents, My Blue Heaven, Office Space </movies>
652
+ <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>
653
+ <name>Dave Fetterman</name>
654
+ <notes_count>0</notes_count>
655
+ <pic>http://photos-055.facebook.com/ip007/profile3/1271/65/s8055_39735.jpg</pic>
656
+ <pic_big>http://photos-055.facebook.com/ip007/profile3/1271/65/n8055_39735.jpg</pic_big>
657
+ <pic_small>http://photos-055.facebook.com/ip007/profile3/1271/65/t8055_39735.jpg</pic_small>
658
+ <pic_square>http://photos-055.facebook.com/ip007/profile3/1271/65/q8055_39735.jpg</pic_square>
659
+ <political>Moderate</political>
660
+ <profile_update_time>1170414620</profile_update_time>
661
+ <quotes/>
662
+ <relationship_status>In a Relationship</relationship_status>
663
+ <religion/>
664
+ <sex>male</sex>
665
+ <significant_other_id xsi:nil="true"/>
666
+ <status>
667
+ <message>I rule</message>
668
+ <time>0</time>
669
+ </status>
670
+ <timezone>-8</timezone>
671
+ <tv>cf. Bob Trahan</tv>
672
+ <wall_count>121</wall_count>
673
+ <work_history list="true">
674
+ <work_info>
675
+ <location>
676
+ <city>Palo Alto</city>
677
+ <state>CA</state>
678
+ <country>United States</country>
679
+ </location>
680
+ <company_name>Facebook</company_name>
681
+ <position>Software Engineer</position>
682
+ <description>Tech Lead, Facebook Platform</description>
683
+ <start_date>2006-01</start_date>
684
+ <end_date/>
685
+ </work_info>
686
+ </work_history>
687
+ </user>
688
+ <user>
689
+ <uid>1240079</uid>
690
+ <about_me>I am here.</about_me>
691
+ <activities>Party.</activities>
692
+ </user>
693
+ </users_getInfo_response>
694
+ XML
695
+ end
696
+
697
+ def example_limited_user_info_xml
698
+ <<-XML
699
+ <?xml version="1.0" encoding="UTF-8"?>
700
+ <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">
701
+ <user>
702
+ <uid>222333</uid>
703
+ <affiliations list="true">
704
+ <affiliation>
705
+ <nid>50453093</nid>
706
+ <name>Facebook Developers</name>
707
+ <type>work</type>
708
+ <status/>
709
+ <year/>
710
+ </affiliation>
711
+ </affiliations>
712
+ <meeting_for list="true">
713
+ <seeking>Friendship</seeking>
714
+ </meeting_for>
715
+ <status>
716
+ <message>I rule</message>
717
+ <time>0</time>
718
+ </status>
719
+ </user>
720
+ <user>
721
+ <uid>1240079</uid>
722
+ <activities>Party.</activities>
723
+ </user>
724
+ </users_getInfo_response>
725
+ XML
726
+ end
727
+
728
+
729
+ def example_nil_user_info_xml
730
+ <<-XML
731
+ <?xml version="1.0" encoding="UTF-8"?>
732
+ <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">
733
+ <user>
734
+ <uid>222333</uid>
735
+ <name>Kevin Lochner</name>
736
+ <current_location xsi:nil="true"/>
737
+ <pic xsi:nil="true"/>
738
+ </user>
739
+ </users_getInfo_response>
740
+ XML
741
+ end
742
+
743
+
744
+ def example_friends_xml
745
+ <<-XML
746
+ <?xml version="1.0" encoding="UTF-8"?>
747
+ <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">
748
+ <uid>222333</uid>
749
+ <uid>1240079</uid>
750
+ </friends_get_response>
751
+ XML
752
+ end
753
+
754
+ def example_friend_lists_xml
755
+ <<-XML
756
+ <?xml version="1.0" encoding="UTF-8"?>
757
+ <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">
758
+ <friendlist>
759
+ <flid>12089150545</flid>
760
+ <name>Family</name>
761
+ </friendlist>
762
+ <friendlist>
763
+ <flid>16361710545</flid>
764
+ <name>Entrepreneuer</name>
765
+ </friendlist>
766
+ </friends_getLists_response>
767
+ XML
768
+ end
769
+
770
+ def example_get_logged_in_user_xml
771
+ <<-XML
772
+ <?xml version="1.0" encoding="UTF-8"?>
773
+ <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>
774
+ XML
775
+ end
776
+
777
+ def example_invalid_api_key_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>101</error_code>
782
+ <error_msg>Invalid API key</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_session_expired_error_response
806
+ <<-XML
807
+ <?xml version="1.0" encoding="UTF-8"?>
808
+ <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">
809
+ <error_code>102</error_code>
810
+ <error_msg>Session Expired</error_msg>
811
+ <request_args list="true">
812
+ <arg>
813
+ <key>v</key>
814
+ <value>1.0</value>
815
+ </arg>
816
+ <arg>
817
+ <key>method</key>
818
+ <value>facebook.auth.createToken</value>
819
+ </arg>
820
+ <arg>
821
+ <key>sig</key>
822
+ <value>611f5f44e55f3fe17f858a8de84a4b0a</value>
823
+ </arg>
824
+ <arg>
825
+ <key>call_id</key>
826
+ <value>1186088346.82142</value>
827
+ </arg>
828
+ </request_args>
829
+ </error_response>
830
+ XML
831
+ end
832
+
833
+ def example_app_users_xml
834
+ <<-XML
835
+ <?xml version="1.0" encoding="UTF-8"?>
836
+ <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">
837
+ <uid>222333</uid>
838
+ <uid>1240079</uid>
839
+ </friends_getAppUsers_response>
840
+ XML
841
+ end
842
+
843
+ def example_comments_xml
844
+ <<-XML
845
+ <?xml version="1.0" encoding="UTF-8"?>
846
+ <comments_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">
847
+ <comment>
848
+ <xid>pete_comments</xid>
849
+ <fromid>563683308</fromid>
850
+ <time>1234227529</time>
851
+ <text>Hola</text>
852
+ <id>65020</id>
853
+ </comment>
854
+ <comment>
855
+ <xid>pete_comments</xid>
856
+ <fromid>563683308</fromid>
857
+ <time>1234227542</time>
858
+ <text>holla</text>
859
+ <id>65021</id>
860
+ </comment>
861
+ </comments_get_response>
862
+ XML
863
+ end
864
+
865
+ def example_user_albums_xml
866
+ <<-XML
867
+ <?xml version="1.0" encoding="UTF-8"?>
868
+ <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">
869
+ <album>
870
+ <aid>97503428432802022</aid>
871
+ <cover_pid>97503428461115574</cover_pid>
872
+ <owner>22701786</owner>
873
+ <name>Summertime is Best</name>
874
+ <created>1184120648</created>
875
+ <modified>1185465771</modified>
876
+ <description>Happenings on or around Summer '07</description>
877
+ <location>Brooklyn, New York</location>
878
+ <link>http://www.facebook.com/album.php?aid=2011366&amp;id=22701786</link>
879
+ <size>49</size>
880
+ </album>
881
+ <album>
882
+ <aid>97503428432797817</aid>
883
+ <cover_pid>97503428460977993</cover_pid>
884
+ <owner>22701786</owner>
885
+ <name>Bonofon's Recital</name>
886
+ <created>1165356279</created>
887
+ <modified>1165382364</modified>
888
+ <description>The whole Ewing fam flies out to flatland to watch the Bonofon's senior recital. That boy sure can tinkle them ivories.</description>
889
+ <location>Grinnell College, Grinnell Iowa</location>
890
+ <link>http://www.facebook.com/album.php?aid=2007161&amp;id=22701786</link>
891
+ <size>14</size>
892
+ </album>
893
+ </photos_getAlbums_response>
894
+ XML
895
+ end
896
+
897
+ def example_user_stream_xml
898
+ <<-XML
899
+ <?xml version="1.0" encoding="UTF-8"?>
900
+ <stream_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">
901
+ <posts list="true">
902
+ <stream_post>
903
+ <post_id>100000637452380_329182455865</post_id>
904
+ <viewer_id>100000637452380</viewer_id>
905
+ <source_id>100000637452380</source_id>
906
+ <type>80</type>
907
+ <app_id>2309869772</app_id>
908
+ <attribution xsi:nil="true"/>
909
+ <actor_id>100000637452380</actor_id>
910
+ <target_id xsi:nil="true"/>
911
+ <message>The bbc home page</message>
912
+ <attachment>
913
+ <media list="true">
914
+ <stream_media>
915
+ <href>http://www.facebook.com/l.php?u=http%253A%252F%252Fwww.bbc.co.uk%252F&amp;h=d6020258c74e511ee6dc1c28746f1e31</href>
916
+ <type>link</type>
917
+ <src>http://external.ak.fbcdn.net/safe_image.php?d=d1e587ce2d7039feaceaf7ef4c2610cd&amp;w=90&amp;h=90&amp;url=http%3A%2F%2Fwww.bbc.co.uk%2Ffeedengine%2Fhomepage%2Fimages%2F_47351229_-1_201x150.jpg</src>
918
+ </stream_media>
919
+ </media>
920
+ <name>BBC - Homepage</name>
921
+ <href>http://www.facebook.com/l.php?u=http%253A%252F%252Fwww.bbc.co.uk%252F&amp;h=d6020258c74e511ee6dc1c28746f1e31</href>
922
+ <caption>www.bbc.co.uk</caption>
923
+ <description>Breaking news, sport, TV, radio and a whole lot more. The BBC informs, educates and entertains - wherever you are, whatever your age.</description>
924
+ <properties list="true"/>
925
+ <icon>http://static.ak.fbcdn.net/rsrc.php/zAXEX/hash/9yvl71tw.png</icon>
926
+ <fb_object_type/>
927
+ <fb_object_id/>
928
+ </attachment>
929
+ <app_data/>
930
+ <action_links xsi:nil="true"/>
931
+ <comments>
932
+ <can_remove>1</can_remove>
933
+ <can_post>1</can_post>
934
+ <count>1</count>
935
+ <comment_list list="true">
936
+ <comment>
937
+ <fromid>100000702701175</fromid>
938
+ <time>1267118534</time>
939
+ <text>I like this website!</text>
940
+ <id>100000637452380_329182455865_11562840</id>
941
+ </comment>
942
+ </comment_list>
943
+ </comments>
944
+ <likes>
945
+ <href>http://www.facebook.com/social_graph.php?node_id=329182455865&amp;class=LikeManager</href>
946
+ <count>1</count>
947
+ <sample list="true"/>
948
+ <friends list="true">
949
+ <uid>100000702701175</uid>
950
+ </friends>
951
+ <user_likes>0</user_likes>
952
+ <can_like>1</can_like>
953
+ </likes>
954
+ <privacy>
955
+ <description>Everyone</description>
956
+ <value>EVERYONE</value>
957
+ <friends>NO_FRIENDS</friends>
958
+ <networks/>
959
+ <allow/>
960
+ <deny/>
961
+ </privacy>
962
+ <updated_time>1267118534</updated_time>
963
+ <created_time>1267103491</created_time>
964
+ <tagged_ids list="true"/>
965
+ <is_hidden>0</is_hidden>
966
+ <filter_key/>
967
+ <permalink>http://www.facebook.com/profile.php?v=feed&amp;story_fbid=329182455865&amp;id=100000637452380</permalink>
968
+ </stream_post>
969
+ <stream_post>
970
+ <post_id>100000637452380_318491734561</post_id>
971
+ <viewer_id>100000637452380</viewer_id>
972
+ <source_id>100000637452380</source_id>
973
+ <type>237</type>
974
+ <app_id>22108119377</app_id>
975
+ <attribution>Digg.com</attribution>
976
+ <actor_id>100000637452380</actor_id>
977
+ <target_id xsi:nil="true"/>
978
+ <message>What is curling.</message>
979
+ <attachment>
980
+ <media list="true">
981
+ <stream_media>
982
+ <href>http://digg.com/olympics/Curling_Finally_Explained_InfoGraphic?OTC-fbc8</href>
983
+ <type>link</type>
984
+ <src>http://platform.ak.fbcdn.net/www/app_full_proxy.php?app=22108119377&amp;v=1&amp;size=z&amp;cksum=f8ecb50623115ff74e5ea8acd9cf4a2e&amp;src=http%3A%2F%2Fdigg.com%2Folympics%2FCurling_Finally_Explained_InfoGraphic%2Ft.jpg</src>
985
+ </stream_media>
986
+ </media>
987
+ <name>Curling Finally Explained [InfoGraphic]</name>
988
+ <href>http://digg.com/olympics/Curling_Finally_Explained_InfoGraphic?OTC-fbc1</href>
989
+ <caption>Phudki dugg this story on Digg</caption>
990
+ <description>At last, someone makes sense out of the weirdest sport of the Winter Olympics. </description>
991
+ <properties list="true">
992
+ <stream_property>
993
+ <name>Source</name>
994
+ <text>i.imgur.com</text>
995
+ </stream_property>
996
+ <stream_property>
997
+ <name>Diggs</name>
998
+ <text>247</text>
999
+ </stream_property>
1000
+ </properties>
1001
+ <icon>http://photos-b.ak.fbcdn.net/photos-ak-sf2p/v43/113/22108119377/app_2_22108119377_6404.gif</icon>
1002
+ <fb_object_type/>
1003
+ <fb_object_id/>
1004
+ </attachment>
1005
+ <app_data>
1006
+ <attachment_data>{&quot;name&quot;:&quot;Curling Finally Explained [InfoGraphic]&quot;,&quot;href&quot;:&quot;http:\/\/digg.com\/olympics\/Curling_Finally_Explained_InfoGraphic?OTC-fbc1&quot;,&quot;description&quot;:&quot;At last, someone makes sense out of the weirdest sport of the Winter Olympics. &quot;,&quot;media&quot;:[{&quot;type&quot;:&quot;image&quot;,&quot;src&quot;:&quot;http:\/\/digg.com\/olympics\/Curling_Finally_Explained_InfoGraphic\/t.jpg&quot;,&quot;href&quot;:&quot;http:\/\/digg.com\/olympics\/Curling_Finally_Explained_InfoGraphic?OTC-fbc8&quot;}],&quot;caption&quot;:&quot;{*actor*} dugg this story on Digg&quot;,&quot;properties&quot;:{&quot;Source&quot;:&quot;i.imgur.com&quot;,&quot;Diggs&quot;:&quot;247&quot;}}</attachment_data>
1007
+ <images>[{&quot;fbml&quot;:&quot;&lt;img src=\&quot;http:\/\/digg.com\/olympics\/Curling_Finally_Explained_InfoGraphic\/t.jpg\&quot; \/&gt;&quot;,&quot;href&quot;:&quot;http:\/\/digg.com\/olympics\/Curling_Finally_Explained_InfoGraphic?OTC-fbc8&quot;}]</images>
1008
+ </app_data>
1009
+ <action_links xsi:nil="true"/>
1010
+ <comments>
1011
+ <can_remove>1</can_remove>
1012
+ <can_post>1</can_post>
1013
+ <count>0</count>
1014
+ <comment_list list="true"/>
1015
+ </comments>
1016
+ <likes>
1017
+ <href>http://www.facebook.com/social_graph.php?node_id=318491734561&amp;class=LikeManager</href>
1018
+ <count>0</count>
1019
+ <sample list="true"/>
1020
+ <friends list="true"/>
1021
+ <user_likes>0</user_likes>
1022
+ <can_like>1</can_like>
1023
+ </likes>
1024
+ <privacy>
1025
+ <description>Everyone</description>
1026
+ <value>EVERYONE</value>
1027
+ <friends>NO_FRIENDS</friends>
1028
+ <networks/>
1029
+ <allow/>
1030
+ <deny/>
1031
+ </privacy>
1032
+ <updated_time>1266919509</updated_time>
1033
+ <created_time>1266919509</created_time>
1034
+ <tagged_ids list="true"/>
1035
+ <is_hidden>0</is_hidden>
1036
+ <filter_key/>
1037
+ <permalink>http://www.facebook.com/profile.php?v=feed&amp;story_fbid=318491734561&amp;id=100000637452380</permalink>
1038
+ </stream_post>
1039
+ </posts>
1040
+ <profiles list="true">
1041
+ <profile>
1042
+ <id>100000637452380</id>
1043
+ <url>http://www.facebook.com/profile.php?id=100000637452380</url>
1044
+ <name>Phudki Bandar</name>
1045
+ <pic_square>http://profile.ak.fbcdn.net/v22939/1286/112/q100000637452380_2062.jpg</pic_square>
1046
+ <type>user</type>
1047
+ </profile>
1048
+ <profile>
1049
+ <id>100000702701175</id>
1050
+ <url>http://www.facebook.com/profile.php?id=100000702701175</url>
1051
+ <name>Mahmood Tester</name>
1052
+ <pic_square>http://profile.ak.fbcdn.net/v22940/1631/70/q100000702701175_5464.jpg</pic_square>
1053
+ <type>user</type>
1054
+ </profile>
1055
+ </profiles>
1056
+ <albums list="true"/>
1057
+ </stream_get_response>
1058
+ XML
1059
+ end
1060
+
1061
+ def example_upload_photo_xml
1062
+ <<-XML
1063
+ <?xml version="1.0" encoding="UTF-8"?>
1064
+ <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">
1065
+ <pid>940915697041656</pid>
1066
+ <aid>940915667462717</aid>
1067
+ <owner>219074</owner>
1068
+ <src>http://ip002.facebook.com/v67/161/72/219074/s219074_31637752_5455.jpg</src>
1069
+ <src_big>http://ip002.facebook.com/v67/161/72/219074/n219074_31637752_5455.jpg</src_big>
1070
+ <src_small>http://ip002.facebook.com/v67/161/72/219074/t219074_31637752_5455.jpg</src_small>
1071
+ <link>http://www.facebook.com/photo.php?pid=31637752&amp;id=219074</link>
1072
+ <caption>Under the sunset</caption>
1073
+ </photos_upload_response>
1074
+ XML
1075
+ end
1076
+
1077
+ def example_new_album_xml
1078
+ <<-XML
1079
+ <?xml version="1.0" encoding="UTF-8"?>
1080
+ <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">
1081
+ <aid>34595963571485</aid>
1082
+ <cover_pid>0</cover_pid>
1083
+ <owner>8055</owner>
1084
+ <name>My Empty Album</name>
1085
+ <created>1132553109</created>
1086
+ <modified>1132553363</modified>
1087
+ <description>No I will not make out with you</description>
1088
+ <location>York, PA</location>
1089
+ <link>http://www.facebook.com/album.php?aid=2002205&amp;id=8055</link>
1090
+ <size>0</size>
1091
+ </photos_createAlbum_response>
1092
+ XML
1093
+ end
1094
+
1095
+ def example_photo_tags_xml
1096
+ <<-XML
1097
+ <?xml version="1.0" encoding="UTF-8"?>
1098
+ <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">
1099
+ <photo_tag>
1100
+ <pid>97503428461115571</pid>
1101
+ <subject>570070524</subject>
1102
+ <xcoord>65.4248</xcoord>
1103
+ <ycoord>16.8627</ycoord>
1104
+ </photo_tag>
1105
+ </photos_getTags_response>
1106
+ XML
1107
+ end
1108
+
1109
+ def example_add_tag_xml
1110
+ <<-XML
1111
+ <?xml version="1.0" encoding="UTF-8"?>
1112
+ <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>
1113
+ XML
1114
+ end
1115
+
1116
+ def example_get_photo_xml
1117
+ <<-XML
1118
+ <?xml version="1.0" encoding="UTF-8"?>
1119
+ <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">
1120
+ <photo>
1121
+ <pid>97503428461115590</pid>
1122
+ <aid>97503428432802022</aid>
1123
+ <owner>22701786</owner>
1124
+ <src>http://photos-c.ak.facebook.com/photos-ak-sf2p/v77/74/112/22701786/s22701786_30324934_7816.jpg</src>
1125
+ <src_big>http://photos-c.ak.facebook.com/photos-ak-sf2p/v77/74/112/22701786/n22701786_30324934_7816.jpg</src_big>
1126
+ <src_small>http://photos-c.ak.facebook.com/photos-ak-sf2p/v77/74/112/22701786/t22701786_30324934_7816.jpg</src_small>
1127
+ <link>http://www.facebook.com/photo.php?pid=30324934&amp;id=22701786</link>
1128
+ <caption>Rooftop barbecues make me act funny</caption>
1129
+ <created>1184120987</created>
1130
+ </photo>
1131
+ <photo>
1132
+ <pid>97503428461115573</pid>
1133
+ <aid>97503428432802022</aid>
1134
+ <owner>22701786</owner>
1135
+ <src>http://photos-b.ak.facebook.com/photos-ak-sf2p/v77/74/112/22701786/s22701786_30324917_4555.jpg</src>
1136
+ <src_big>http://photos-b.ak.facebook.com/photos-ak-sf2p/v77/74/112/22701786/n22701786_30324917_4555.jpg</src_big>
1137
+ <src_small>http://photos-b.ak.facebook.com/photos-ak-sf2p/v77/74/112/22701786/t22701786_30324917_4555.jpg</src_small>
1138
+ <link>http://www.facebook.com/photo.php?pid=30324917&amp;id=22701786</link>
1139
+ <caption/>
1140
+ <created>1184120654</created>
1141
+ </photo>
1142
+ </photos_get_response>
1143
+ XML
1144
+ end
1145
+
1146
+ def example_upload_video_xml
1147
+ <<-XML
1148
+ <?xml version="1.0" encoding="UTF-8"?>
1149
+ <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">
1150
+ <vid>15943367753</vid>
1151
+ <title>Some Epic</title>
1152
+ <description>Check it out</description>
1153
+ <link>http://www.facebook.com/video/video.php?v=15943367753</link>
1154
+ </video_upload_response>
1155
+ XML
1156
+ end
1157
+
1158
+ def example_revoke_authorization_true
1159
+ "1"
1160
+ end
1161
+
1162
+ def example_revoke_authorization_false
1163
+ "0"
1164
+ end
1165
+
1166
+
1167
+ def example_remove_comment_true
1168
+ "1"
1169
+ end
1170
+
1171
+ def example_remove_comment_false
1172
+ "0"
1173
+ end
1174
+
1175
+ end