facebooker 1.0.62 → 1.0.63

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -78,6 +78,7 @@ lib/facebooker/models/tag.rb
78
78
  lib/facebooker/models/user.rb
79
79
  lib/facebooker/models/video.rb
80
80
  lib/facebooker/models/work_info.rb
81
+ lib/facebooker/models/message_thread.rb
81
82
  lib/facebooker/parser.rb
82
83
  lib/facebooker/rails/backwards_compatible_param_checks.rb
83
84
  lib/facebooker/rails/controller.rb
data/facebooker.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  * Well tested}
16
16
  s.email = ["chad@chadfowlwer.com", "", "", "", "", "mmangino@elevatedrails.com"]
17
17
  s.extra_rdoc_files = ["Manifest.txt", "CHANGELOG.rdoc", "COPYING.rdoc", "README.rdoc", "TODO.rdoc"]
18
- s.files = [".autotest", "CHANGELOG.rdoc", "COPYING.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "TODO.rdoc", "examples/desktop_login.rb", "facebooker.gemspec", "generators/facebook/facebook_generator.rb", "generators/facebook/templates/config/facebooker.yml", "generators/facebook/templates/public/javascripts/facebooker.js", "generators/facebook_controller/USAGE", "generators/facebook_controller/facebook_controller_generator.rb", "generators/facebook_controller/templates/controller.rb", "generators/facebook_controller/templates/functional_test.rb", "generators/facebook_controller/templates/helper.rb", "generators/facebook_controller/templates/view.fbml.erb", "generators/facebook_controller/templates/view.html.erb", "generators/facebook_publisher/facebook_publisher_generator.rb", "generators/facebook_publisher/templates/create_facebook_templates.rb", "generators/facebook_publisher/templates/publisher.rb", "generators/facebook_scaffold/USAGE", "generators/facebook_scaffold/facebook_scaffold_generator.rb", "generators/facebook_scaffold/templates/controller.rb", "generators/facebook_scaffold/templates/facebook_style.css", "generators/facebook_scaffold/templates/functional_test.rb", "generators/facebook_scaffold/templates/helper.rb", "generators/facebook_scaffold/templates/layout.fbml.erb", "generators/facebook_scaffold/templates/layout.html.erb", "generators/facebook_scaffold/templates/style.css", "generators/facebook_scaffold/templates/view_edit.fbml.erb", "generators/facebook_scaffold/templates/view_edit.html.erb", "generators/facebook_scaffold/templates/view_index.fbml.erb", "generators/facebook_scaffold/templates/view_index.html.erb", "generators/facebook_scaffold/templates/view_new.fbml.erb", "generators/facebook_scaffold/templates/view_new.html.erb", "generators/facebook_scaffold/templates/view_show.fbml.erb", "generators/facebook_scaffold/templates/view_show.html.erb", "generators/publisher/publisher_generator.rb", "generators/xd_receiver/templates/xd_receiver_ssl.html", "generators/xd_receiver/templates/xd_receiver.html", "generators/xd_receiver/xd_receiver_generator.rb", "init.rb", "install.rb", "lib/facebooker.rb", "lib/facebooker/adapters/adapter_base.rb", "lib/facebooker/adapters/bebo_adapter.rb", "lib/facebooker/adapters/facebook_adapter.rb", "lib/facebooker/attachment.rb", "lib/facebooker/admin.rb", "lib/facebooker/application.rb", "lib/facebooker/batch_request.rb", "lib/facebooker/data.rb", "lib/facebooker/feed.rb", "lib/facebooker/logging.rb", "lib/facebooker/mobile.rb", "lib/facebooker/mock/service.rb", "lib/facebooker/mock/session.rb", "lib/facebooker/model.rb", "lib/facebooker/models/affiliation.rb", "lib/facebooker/models/album.rb", "lib/facebooker/models/applicationproperties.rb", "lib/facebooker/models/applicationrestrictions.rb", "lib/facebooker/models/cookie.rb", "lib/facebooker/models/education_info.rb", "lib/facebooker/models/event.rb", "lib/facebooker/models/family_relative_info.rb", "lib/facebooker/models/friend_list.rb", "lib/facebooker/models/group.rb", "lib/facebooker/models/info_item.rb", "lib/facebooker/models/info_section.rb", "lib/facebooker/models/location.rb", "lib/facebooker/models/notifications.rb", "lib/facebooker/models/page.rb", "lib/facebooker/models/photo.rb", "lib/facebooker/models/tag.rb", "lib/facebooker/models/user.rb", "lib/facebooker/models/video.rb", "lib/facebooker/models/work_info.rb", "lib/facebooker/parser.rb", "lib/facebooker/rails/backwards_compatible_param_checks.rb", "lib/facebooker/rails/controller.rb", "lib/facebooker/rails/cucumber.rb", "lib/facebooker/rails/cucumber/world.rb", "lib/facebooker/rails/extensions/action_controller.rb", "lib/facebooker/rails/extensions/rack_setup.rb", "lib/facebooker/rails/extensions/routing.rb", "lib/facebooker/rails/facebook_form_builder.rb", "lib/facebooker/rails/facebook_pretty_errors.rb", "lib/facebooker/rails/facebook_request_fix.rb", "lib/facebooker/rails/facebook_request_fix_2-3.rb", "lib/facebooker/rails/facebook_session_handling.rb", "lib/facebooker/rails/facebook_url_helper.rb", "lib/facebooker/rails/facebook_url_rewriting.rb", "lib/facebooker/rails/helpers.rb", "lib/facebooker/rails/helpers/fb_connect.rb", "lib/facebooker/rails/helpers/stream_publish.rb", "lib/facebooker/rails/integration_session.rb", "lib/facebooker/rails/profile_publisher_extensions.rb", "lib/facebooker/rails/publisher.rb", "lib/facebooker/rails/routing.rb", "lib/facebooker/rails/test_helpers.rb", "lib/facebooker/rails/utilities.rb", "lib/facebooker/server_cache.rb", "lib/facebooker/service.rb", "lib/facebooker/service/base_service.rb", "lib/facebooker/service/curl_service.rb", "lib/facebooker/service/net_http_service.rb", "lib/facebooker/service/typhoeus_service.rb", "lib/facebooker/service/typhoeus_multi_service.rb", "lib/facebooker/session.rb", "lib/facebooker/stream_post.rb", "lib/facebooker/version.rb", "lib/net/http_multipart_post.rb", "lib/rack/facebook.rb", "lib/rack/facebook_session.rb", "lib/tasks/facebooker.rake", "lib/tasks/facebooker.rb", "lib/tasks/tunnel.rake", "rails/init.rb", "setup.rb", "templates/layout.erb", "test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/application_test.rb", "test/facebooker/attachment_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/page_test.rb", "test/facebooker/models/photo_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/rails/facebook_request_fix_2-3_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/fixtures/multipart_post_body_with_only_parameters.txt", "test/fixtures/multipart_post_body_with_single_file.txt", "test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt", "test/net/http_multipart_post_test.rb", "test/rack/facebook_test.rb", "test/rack/facebook_session_test.rb", "test/rails_test_helper.rb", "test/test_helper.rb", "test/facebooker/rails/facebook_url_rewriting_test.rb", "test/facebooker/rails/integration_session_test.rb", "test/facebooker/service_test.rb"]
18
+ s.files = [".autotest", "CHANGELOG.rdoc", "COPYING.rdoc", "Manifest.txt", "README.rdoc", "Rakefile", "TODO.rdoc", "examples/desktop_login.rb", "facebooker.gemspec", "generators/facebook/facebook_generator.rb", "generators/facebook/templates/config/facebooker.yml", "generators/facebook/templates/public/javascripts/facebooker.js", "generators/facebook_controller/USAGE", "generators/facebook_controller/facebook_controller_generator.rb", "generators/facebook_controller/templates/controller.rb", "generators/facebook_controller/templates/functional_test.rb", "generators/facebook_controller/templates/helper.rb", "generators/facebook_controller/templates/view.fbml.erb", "generators/facebook_controller/templates/view.html.erb", "generators/facebook_publisher/facebook_publisher_generator.rb", "generators/facebook_publisher/templates/create_facebook_templates.rb", "generators/facebook_publisher/templates/publisher.rb", "generators/facebook_scaffold/USAGE", "generators/facebook_scaffold/facebook_scaffold_generator.rb", "generators/facebook_scaffold/templates/controller.rb", "generators/facebook_scaffold/templates/facebook_style.css", "generators/facebook_scaffold/templates/functional_test.rb", "generators/facebook_scaffold/templates/helper.rb", "generators/facebook_scaffold/templates/layout.fbml.erb", "generators/facebook_scaffold/templates/layout.html.erb", "generators/facebook_scaffold/templates/style.css", "generators/facebook_scaffold/templates/view_edit.fbml.erb", "generators/facebook_scaffold/templates/view_edit.html.erb", "generators/facebook_scaffold/templates/view_index.fbml.erb", "generators/facebook_scaffold/templates/view_index.html.erb", "generators/facebook_scaffold/templates/view_new.fbml.erb", "generators/facebook_scaffold/templates/view_new.html.erb", "generators/facebook_scaffold/templates/view_show.fbml.erb", "generators/facebook_scaffold/templates/view_show.html.erb", "generators/publisher/publisher_generator.rb", "generators/xd_receiver/templates/xd_receiver_ssl.html", "generators/xd_receiver/templates/xd_receiver.html", "generators/xd_receiver/xd_receiver_generator.rb", "init.rb", "install.rb", "lib/facebooker.rb", "lib/facebooker/adapters/adapter_base.rb", "lib/facebooker/adapters/bebo_adapter.rb", "lib/facebooker/adapters/facebook_adapter.rb", "lib/facebooker/attachment.rb", "lib/facebooker/admin.rb", "lib/facebooker/application.rb", "lib/facebooker/batch_request.rb", "lib/facebooker/data.rb", "lib/facebooker/feed.rb", "lib/facebooker/logging.rb", "lib/facebooker/mobile.rb", "lib/facebooker/mock/service.rb", "lib/facebooker/mock/session.rb", "lib/facebooker/model.rb", "lib/facebooker/models/affiliation.rb", "lib/facebooker/models/album.rb", "lib/facebooker/models/applicationproperties.rb", "lib/facebooker/models/applicationrestrictions.rb", "lib/facebooker/models/cookie.rb", "lib/facebooker/models/education_info.rb", "lib/facebooker/models/event.rb", "lib/facebooker/models/family_relative_info.rb", "lib/facebooker/models/friend_list.rb", "lib/facebooker/models/group.rb", "lib/facebooker/models/info_item.rb", "lib/facebooker/models/info_section.rb", "lib/facebooker/models/location.rb", "lib/facebooker/models/notifications.rb", "lib/facebooker/models/page.rb", "lib/facebooker/models/photo.rb", "lib/facebooker/models/tag.rb", "lib/facebooker/models/user.rb", "lib/facebooker/models/video.rb", "lib/facebooker/models/work_info.rb", "lib/facebooker/models/message_thread.rb", "lib/facebooker/parser.rb", "lib/facebooker/rails/backwards_compatible_param_checks.rb", "lib/facebooker/rails/controller.rb", "lib/facebooker/rails/cucumber.rb", "lib/facebooker/rails/cucumber/world.rb", "lib/facebooker/rails/extensions/action_controller.rb", "lib/facebooker/rails/extensions/rack_setup.rb", "lib/facebooker/rails/extensions/routing.rb", "lib/facebooker/rails/facebook_form_builder.rb", "lib/facebooker/rails/facebook_pretty_errors.rb", "lib/facebooker/rails/facebook_request_fix.rb", "lib/facebooker/rails/facebook_request_fix_2-3.rb", "lib/facebooker/rails/facebook_session_handling.rb", "lib/facebooker/rails/facebook_url_helper.rb", "lib/facebooker/rails/facebook_url_rewriting.rb", "lib/facebooker/rails/helpers.rb", "lib/facebooker/rails/helpers/fb_connect.rb", "lib/facebooker/rails/helpers/stream_publish.rb", "lib/facebooker/rails/integration_session.rb", "lib/facebooker/rails/profile_publisher_extensions.rb", "lib/facebooker/rails/publisher.rb", "lib/facebooker/rails/routing.rb", "lib/facebooker/rails/test_helpers.rb", "lib/facebooker/rails/utilities.rb", "lib/facebooker/server_cache.rb", "lib/facebooker/service.rb", "lib/facebooker/service/base_service.rb", "lib/facebooker/service/curl_service.rb", "lib/facebooker/service/net_http_service.rb", "lib/facebooker/service/typhoeus_service.rb", "lib/facebooker/service/typhoeus_multi_service.rb", "lib/facebooker/session.rb", "lib/facebooker/stream_post.rb", "lib/facebooker/version.rb", "lib/net/http_multipart_post.rb", "lib/rack/facebook.rb", "lib/rack/facebook_session.rb", "lib/tasks/facebooker.rake", "lib/tasks/facebooker.rb", "lib/tasks/tunnel.rake", "rails/init.rb", "setup.rb", "templates/layout.erb", "test/facebooker/adapters_test.rb", "test/facebooker/admin_test.rb", "test/facebooker/application_test.rb", "test/facebooker/attachment_test.rb", "test/facebooker/batch_request_test.rb", "test/facebooker/data_test.rb", "test/facebooker/logging_test.rb", "test/facebooker/mobile_test.rb", "test/facebooker/model_test.rb", "test/facebooker/models/event_test.rb", "test/facebooker/models/page_test.rb", "test/facebooker/models/photo_test.rb", "test/facebooker/models/user_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/rails/facebook_request_fix_2-3_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/fixtures/multipart_post_body_with_only_parameters.txt", "test/fixtures/multipart_post_body_with_single_file.txt", "test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt", "test/net/http_multipart_post_test.rb", "test/rack/facebook_test.rb", "test/rack/facebook_session_test.rb", "test/rails_test_helper.rb", "test/test_helper.rb", "test/facebooker/rails/facebook_url_rewriting_test.rb", "test/facebooker/rails/integration_session_test.rb", "test/facebooker/service_test.rb"]
19
19
  s.homepage = %q{http://facebooker.rubyforge.org}
20
20
  s.rdoc_options = ["--main", "README.rdoc"]
21
21
  s.require_paths = ["lib"]
data/lib/facebooker.rb CHANGED
@@ -254,6 +254,7 @@ require 'facebooker/models/info_item'
254
254
  require 'facebooker/models/info_section'
255
255
  require 'facebooker/models/friend_list'
256
256
  require 'facebooker/models/video'
257
+ require 'facebooker/models/message_thread'
257
258
  require 'facebooker/adapters/adapter_base'
258
259
  require 'facebooker/adapters/facebook_adapter'
259
260
  require 'facebooker/adapters/bebo_adapter'
@@ -0,0 +1,89 @@
1
+ require 'facebooker/model'
2
+ module Facebooker
3
+ class MessageThread
4
+ include Model
5
+
6
+ id_is :thread_id
7
+ attr_accessor :subject, :updated_time, :recipients
8
+ attr_accessor :parent_message_id, :parent_thread_id, :message_count
9
+ attr_accessor :snippet, :snippet_author, :object_id, :unread
10
+
11
+ class Message
12
+ include Model
13
+
14
+ attr_accessor :message_id, :author_id, :body, :created_time, :attachment, :thread_id
15
+
16
+ # An attachment can be a photo, a video, or a link
17
+ class Attachment
18
+ include Model
19
+
20
+ attr_accessor :name, :href, :icon, :caption, :description
21
+
22
+ # The Facebook messages API is in beta, this helper method is supposed to fail anytime soon
23
+ def video?
24
+ self.href =~ /\Ahttp:\/\/www\.facebook\.com\/video\/video\.php.*/
25
+ end
26
+
27
+ # The Facebook messages API is in beta, this helper method is supposed to fail anytime soon
28
+ def photo?
29
+ self.href =~ /\Ahttp:\/\/www\.facebook\.com\/photo\.php.*/
30
+ end
31
+
32
+ # The Facebook messages API is in beta, this helper method is supposed to fail anytime soon
33
+ def link?
34
+ !video? && !photo?
35
+ end
36
+ end
37
+ hash_settable_accessor :attachment, Facebooker::MessageThread::Message::Attachment
38
+ end
39
+ hash_settable_list_accessor :messages, Facebooker::MessageThread::Message
40
+
41
+ end
42
+ end
43
+
44
+ # Example of attachments
45
+
46
+ # -- Photo --
47
+
48
+ # <attachment>
49
+ # <media list="true"/>
50
+ # <href>http://www.facebook.com/photo.php?pid=12345&amp;id=54321</href>
51
+ # <properties list="true"/>
52
+ # <icon>http://b.static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif</icon>
53
+ # <fb_object_type/>
54
+ # <fb_object_id/>
55
+ # <tagged_ids list="true"/>
56
+ # </attachment>
57
+
58
+ # -- Webcam video --
59
+
60
+ # <attachment>
61
+ # <media list="true"/>
62
+ # <name>Feb 10, 2010 1:26pm</name>
63
+ # <href>http://www.facebook.com/video/video.php?v=12345</href>
64
+ # <properties list="true"/>
65
+ # <icon>http://static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif</icon>
66
+ # <fb_object_type/>
67
+ # <fb_object_id/>
68
+ # <tagged_ids list="true"/>
69
+ # </attachment>
70
+
71
+ # -- Link --
72
+
73
+ # <attachment>
74
+ # <media list="true">
75
+ # <stream_media>
76
+ # <href>http://www.facebook.com/l.php?u=http%253A%252F%252Fwww.google.fr%252F&amp;h=e46dd63cdbfadb74958fbe44e98f339c</href>
77
+ # <type>link</type>
78
+ # <src>http://external.ak.fbcdn.net/safe_image.php?d=dd54bba6b6e6479a89bb8084573c02c8&amp;w=90&amp;h=90&amp;url=http%3A%2F%2Fwww.google.fr%2Fintl%2Ffr_fr%2Fimages%2Flogo.gif</src>
79
+ # </stream_media>
80
+ # </media>
81
+ # <name>Google</name>
82
+ # <href>http://www.facebook.com/l.php?u=http%253A%252F%252Fwww.google.fr%252F&amp;h=e46dd63cdbfadb74958fbe44e98f339c</href>
83
+ # <caption>www.google.fr</caption>
84
+ # <properties list="true"/>
85
+ # <icon>http://b.static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif</icon>
86
+ # <fb_object_type/>
87
+ # <fb_object_id/>
88
+ # <tagged_ids list="true"/>
89
+ # </attachment>
@@ -26,7 +26,7 @@ module Facebooker
26
26
  end
27
27
 
28
28
  include Model
29
- attr_accessor :page_id,:name,:pic_small,:pic_big,:pic_square,:pic,:pic_large,:type,:website,:has_added_app,:founded,:company_overview,:mission,:products,:location,:parking,:public_transit,:hours,:attire,:payment_options,:culinary_team,:general_manager,:price_range,:restaurant_services,:restaurant_specialties,:release_date,:genre,:starring,:screenplay_by,:directed_by,:produced_by,:studio,:awards,:plot_outline,:network,:season,:schedule,:written_by,:band_members,:hometown,:current_location,:record_label,:booking_agent,:artists_we_like,:influences,:band_interests,:bio,:affiliation,:birthday,:personal_info,:personal_interests,:members,:built,:features,:mpg,:general_info,:fan_count
29
+ attr_accessor :page_id,:name,:pic_small,:pic_big,:pic_square,:pic,:pic_large,:type,:website,:has_added_app,:founded,:company_overview,:mission,:products,:location,:parking,:public_transit,:hours,:attire,:payment_options,:culinary_team,:general_manager,:price_range,:restaurant_services,:restaurant_specialties,:release_date,:genre,:starring,:screenplay_by,:directed_by,:produced_by,:studio,:awards,:plot_outline,:network,:season,:schedule,:written_by,:band_members,:hometown,:current_location,:record_label,:booking_agent,:artists_we_like,:influences,:band_interests,:bio,:affiliation,:birthday,:personal_info,:personal_interests,:members,:built,:features,:mpg,:general_info,:fan_count,:page_url
30
30
  attr_reader :genre
31
31
 
32
32
  alias_method :id, :page_id
@@ -246,6 +246,21 @@ module Facebooker
246
246
  end
247
247
  end
248
248
 
249
+ ###
250
+ # Get threads in a folder
251
+ #
252
+ # See: http://wiki.developers.facebook.com/index.php/Message.getThreadsInFolder
253
+ #
254
+ # +options+ possible options are :folder_id, :limit and :offset
255
+ def threads(options = {})
256
+ options ||= {}
257
+ @threads = session.post('facebook.message.getThreadsInFolder', options) do |response|
258
+ response.map do |hash|
259
+ MessageThread.from_hash(hash)
260
+ end
261
+ end
262
+ end
263
+
249
264
  def notifications
250
265
  @notifications ||= Notifications.from_hash(session.post('facebook.notifications.get'))
251
266
  end
@@ -330,6 +330,12 @@ module Facebooker
330
330
  end
331
331
  end
332
332
 
333
+ class MessageGetThreadsInFolder < Parser#:nodoc:
334
+ def self.process(data)
335
+ array_of_hashes(element('message_getThreadsInFolder_response', data), 'thread')
336
+ end
337
+ end
338
+
333
339
  class NotificationsGet < Parser#:nodoc:
334
340
  def self.process(data)
335
341
  hashinate(element('notifications_get_response', data))
@@ -636,6 +642,7 @@ module Facebooker
636
642
  604 => Facebooker::Session::FQLStatementNotIndexable,
637
643
  605 => Facebooker::Session::FQLFunctionDoesNotExist,
638
644
  606 => Facebooker::Session::FQLWrongNumberArgumentsPassedToFunction,
645
+ 612 => Facebooker::Session::ReadMailboxExtendedPermissionRequired,
639
646
  807 => Facebooker::Session::TemplateBundleInvalid
640
647
  }
641
648
  def self.process(data)
@@ -676,6 +683,7 @@ module Facebooker
676
683
  'facebook.feed.deactivateTemplateBundleByID' => DeactivateTemplateBundleByID,
677
684
  'facebook.feed.getRegisteredTemplateBundles' => GetRegisteredTemplateBundles,
678
685
  'facebook.feed.publishUserAction' => PublishUserAction,
686
+ 'facebook.message.getThreadsInFolder' => MessageGetThreadsInFolder,
679
687
  'facebook.notifications.get' => NotificationsGet,
680
688
  'facebook.notifications.send' => NotificationsSend,
681
689
  'facebook.notifications.sendRequest' => SendRequest,
@@ -246,7 +246,7 @@ module Facebooker
246
246
  )
247
247
  end
248
248
 
249
- def fbml_redirect_tag(url)
249
+ def fbml_redirect_tag(url,*args)
250
250
  "<fb:redirect url=\"#{url_for(url)}\" />"
251
251
  end
252
252
 
@@ -341,7 +341,7 @@ module Facebooker
341
341
  VALID_FB_PHOTO_SIZES = VALID_FB_SHARED_PHOTO_SIZES
342
342
  VALID_FB_PROFILE_PIC_SIZES = VALID_FB_SHARED_PHOTO_SIZES
343
343
  VALID_PERMISSIONS=[:email, :offline_access, :status_update, :photo_upload, :create_listing, :create_event, :rsvp_event, :sms, :video_upload,
344
- :publish_stream, :read_stream]
344
+ :publish_stream, :read_stream, :read_mailbox]
345
345
 
346
346
  # Render an fb:tabs tag containing some number of fb:tab_item tags.
347
347
  # Example:
@@ -624,6 +624,7 @@ module Facebooker
624
624
  # * video_upload
625
625
  # * create_note
626
626
  # * share_item
627
+ # * read_mailbox
627
628
  # Example:
628
629
  # <%= fb_prompt_permission('email', "Would you like to receive email from our application?" ) %>
629
630
  #
@@ -56,6 +56,7 @@ module Facebooker
56
56
  class MissingOrInvalidImageFile < StandardError; end
57
57
  class TooManyUnapprovedPhotosPending < StandardError; end
58
58
  class ExtendedPermissionRequired < StandardError; end
59
+ class ReadMailboxExtendedPermissionRequired < StandardError; end
59
60
  class InvalidFriendList < StandardError; end
60
61
  class UserUnRegistrationFailed < StandardError
61
62
  attr_accessor :failed_users
@@ -120,6 +121,7 @@ module Facebooker
120
121
  # * create_event
121
122
  # * rsvp_event
122
123
  # * sms
124
+ # * read_mailbox
123
125
  def permission_url(permission,options={})
124
126
  options = default_login_url_options.merge(options)
125
127
  options = add_next_parameters(options)
@@ -2,7 +2,7 @@ module Facebooker #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 62
5
+ TINY = 63
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -6,13 +6,14 @@ namespace :facebooker do
6
6
  task :setup => :environment do
7
7
  facebook_config = File.join(RAILS_ROOT,"config","facebooker.yml")
8
8
  unless File.exist?(facebook_config)
9
- FileUtils.cp File.join(RAILS_ROOT,"vendor", "plugins", "facebooker", "facebooker.yml.tpl"), facebook_config
9
+ plugin_root = File.join(RAILS_ROOT,"vendor","plugins")
10
+ facebook_config_tpl = File.join(plugin_root,"facebooker","generators","facebook","templates","config","facebooker.yml")
11
+ FileUtils.cp facebook_config_tpl, facebook_config
10
12
  puts "Ensure 'GatewayPorts yes' is enabled in the remote development server's sshd config when using any of the facebooker:tunnel:*' rake tasks"
11
13
  puts "Configuration created in #{RAILS_ROOT}/config/facebooker.yml"
12
14
  else
13
15
  puts "#{RAILS_ROOT}/config/facebooker.yml already exists"
14
16
  end
15
- end
16
-
17
- end
18
-
17
+ end
18
+
19
+ end
@@ -321,7 +321,47 @@ class Facebooker::UserTest < Test::Unit::TestCase
321
321
  assert result
322
322
  end
323
323
 
324
- private
324
+ def test_threads_should_return_an_array_of_thread_instances_containing_messages_and_attachments
325
+ expect_http_posts_with_responses(example_threads)
326
+ threads = @user.threads
327
+ assert_not_nil threads
328
+ assert_instance_of Array, threads
329
+ assert_operator threads.size, :>, 0
330
+ for thread in threads
331
+ assert_instance_of Facebooker::MessageThread, thread
332
+ assert_instance_of Array, thread.messages
333
+ assert_operator thread.messages.size, :>, 0
334
+ assert_instance_of Facebooker::MessageThread::Message, thread.messages.first
335
+
336
+ for message in thread.messages
337
+ next if message.attachment.blank?
338
+ assert_instance_of Facebooker::MessageThread::Message::Attachment, message.attachment
339
+
340
+ case message.message_id
341
+ when '1344434538976_0'
342
+ assert message.attachment.photo?, 'Attachment of message "1344434538976_0" should be a photo'
343
+ when '1344434538976_2'
344
+ assert message.attachment.link?, 'Attachment of message "1344434538976_2" should be a link'
345
+ when '1012985167472_0'
346
+ assert message.attachment.video?, 'Attachment of message "1012985167472_0" should be a video'
347
+ end
348
+ end
349
+ end
350
+ end
351
+
352
+ def test_threads_should_return_populated_fields
353
+ expect_http_posts_with_responses(example_threads)
354
+ threads = @user.threads
355
+
356
+ thread = threads.first
357
+ [:thread_id, :subject, :updated_time, :recipients, :parent_message_id, :parent_thread_id,
358
+ :message_count, :snippet, :snippet_author, :object_id, :unread].each do |field|
359
+ assert_not_nil thread.__send__(field), "Field #{field} should not be nil"
360
+ end
361
+ end
362
+
363
+ private
364
+
325
365
  def example_profile_photos_get_xml
326
366
  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
327
367
  <photos_get_response xmlns=\"http://api.facebook.com/1.0/\"
@@ -446,4 +486,145 @@ class Facebooker::UserTest < Test::Unit::TestCase
446
486
  </events_rsvp_response>
447
487
  E
448
488
  end
489
+
490
+ def example_threads
491
+ <<-XML
492
+ <message_getThreadsInFolder_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">
493
+ <thread>
494
+ <thread_id>1344434538976</thread_id>
495
+ <subject>Test attachments</subject>
496
+ <recipients list="true">
497
+ <uid>1410850842</uid>
498
+ <uid>662074872</uid>
499
+ </recipients>
500
+ <updated_time>1265723631</updated_time>
501
+ <parent_message_id>0</parent_message_id>
502
+ <parent_thread_id>0</parent_thread_id>
503
+ <message_count>3</message_count>
504
+ <snippet>one link attachment to a youtube video</snippet>
505
+ <snippet_author>1410850842</snippet_author>
506
+ <object_id>0</object_id>
507
+ <unread>0</unread>
508
+ <messages list="true">
509
+ <message>
510
+ <message_id>1344434538976_0</message_id>
511
+ <author_id>662074872</author_id>
512
+ <body>one photo attachment , 4KB jpeg image</body>
513
+ <created_time>1265723631</created_time>
514
+ <attachment>
515
+ <media list="true"/>
516
+ <href>http://www.facebook.com/photo.php?pid=3358326&amp;id=662074872</href>
517
+ <properties list="true"/>
518
+ <icon>http://static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif</icon>
519
+ <fb_object_type/>
520
+ <fb_object_id/>
521
+ <tagged_ids list="true"/>
522
+ </attachment>
523
+ <thread_id>1344434538976</thread_id>
524
+ </message>
525
+ <message>
526
+ <message_id>1344434538976_1</message_id>
527
+ <author_id>1410850842</author_id>
528
+ <body>one link attachment (http://www.facebook.com/l/e46dd;google.fr)</body>
529
+ <created_time>1265723941</created_time>
530
+ <attachment>
531
+ <media list="true">
532
+ <stream_media>
533
+ <href>http://www.facebook.com/l.php?u=http%253A%252F%252Fwww.google.fr%252F&amp;h=e46dd63cdbfadb74958fbe44e98f339c</href>
534
+ <type>link</type>
535
+ <src>http://external.ak.fbcdn.net/safe_image.php?d=dd54bba6b6e6479a89bb8084573c02c8&amp;w=90&amp;h=90&amp;url=http%3A%2F%2Fwww.google.fr%2Fintl%2Ffr_fr%2Fimages%2Flogo.gif</src>
536
+ </stream_media>
537
+ </media>
538
+ <name>Google</name>
539
+ <href>http://www.facebook.com/l.php?u=http%253A%252F%252Fwww.google.fr%252F&amp;h=e46dd63cdbfadb74958fbe44e98f339c</href>
540
+ <caption>www.google.fr</caption>
541
+ <properties list="true"/>
542
+ <icon>http://static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif</icon>
543
+ <fb_object_type/>
544
+ <fb_object_id/>
545
+ <tagged_ids list="true"/>
546
+ </attachment>
547
+ <thread_id>1344434538976</thread_id>
548
+ </message>
549
+ <message>
550
+ <message_id>1344434538976_2</message_id>
551
+ <author_id>1410850842</author_id>
552
+ <body>one link attachment to a youtube video</body>
553
+ <created_time>1265726503</created_time>
554
+ <attachment>
555
+ <media list="true">
556
+ <stream_media>
557
+ <href>http://www.facebook.com/l.php?u=http%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DAW-sNQUmUIM%2526feature%253Dpopular&amp;h=e46dd63cdbfadb74958fbe44e98f339c</href>
558
+ <alt>super bowl 44 highlights saints vs colts</alt>
559
+ <type>video</type>
560
+ <src>http://external.ak.fbcdn.net/safe_image.php?d=66f4aa965e2ae4a20a11c6a8ae3e4b1b&amp;w=90&amp;h=90&amp;url=http%3A%2F%2Fi.ytimg.com%2Fvi%2FAW-sNQUmUIM%2F2.jpg</src>
561
+ <video>
562
+ <display_url>http://www.youtube.com/watch?v=AW-sNQUmUIM&amp;feature=popular</display_url>
563
+ <source_url>http://www.youtube.com/v/AW-sNQUmUIM&amp;autoplay=1</source_url>
564
+ <owner>1410850842</owner>
565
+ <source_type>html</source_type>
566
+ </video>
567
+ </stream_media>
568
+ </media>
569
+ <name>super bowl 44 highlights saints vs colts</name>
570
+ <href>http://www.facebook.com/l.php?u=http%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DAW-sNQUmUIM%2526feature%253Dpopular&amp;h=e46dd63cdbfadb74958fbe44e98f339c</href>
571
+ <caption>www.youtube.com</caption>
572
+ <description>NFL super bowl 44 highlights saints vs colts from south florida.</description>
573
+ <properties list="true"/>
574
+ <icon>http://static.ak.fbcdn.net/rsrc.php/z9XZ8/hash/976ulj6z.gif</icon>
575
+ <fb_object_type/>
576
+ <fb_object_id/>
577
+ <tagged_ids list="true"/>
578
+ </attachment>
579
+ <thread_id>1344434538976</thread_id>
580
+ </message>
581
+ </messages>
582
+ </thread>
583
+ <thread>
584
+ <thread_id>1012985167472</thread_id>
585
+ <subject>Happy Holidays from the Facebook Platform Team</subject>
586
+ <recipients list="true">
587
+ <uid>220400</uid>
588
+ </recipients>
589
+ <updated_time>1230000685</updated_time>
590
+ <parent_message_id>0</parent_message_id>
591
+ <parent_thread_id>0</parent_thread_id>
592
+ <message_count>1</message_count>
593
+ <snippet>We wanted to take a moment and thank you for all of your great work and amazi...</snippet>
594
+ <snippet_author>220400</snippet_author>
595
+ <object_id>2205007948</object_id>
596
+ <unread>0</unread>
597
+ <messages list="true">
598
+ <message>
599
+ <message_id>1012985167472_0</message_id>
600
+ <author_id>220400</author_id>
601
+ <body>We wanted to take a moment and thank you for all of your great work and amazing applications that have helped make Facebook Platform the largest and fastest-growing social platform over the past year and a half. As we end 2008 there are over 660,000 of you worldwide building applications that give users more powerful ways to share and connect, and collectively your applications have reached nearly 140 million people.
602
+
603
+ Just recently, we've been excited to bring you Facebook Connect - allowing you to integrate the tools and features of Facebook Platform on your Websites, devices and desktop applications. In the next several months, we're looking forward to introducing additional improvements to help users more easily find your applications as well as launching the first sets of Verified Applications to users. If you haven't applied for verification yet, apply here:
604
+ http://developers.facebook.com/verification.php
605
+
606
+ Over the next year, we look forward to continued developments to improve Facebook Platform and help you reach and engage more users, and grow and sustain your business. We would love your feedback and input on what you think is most important - please take a few minutes and answer our survey here:
607
+
608
+ http://www.facebook.com/l/e46dd;https://www.questionpro.com/akira/TakeSurvey?id=1121648
609
+
610
+ From all of us at Facebook, we wish you and your families &quot;Happy Holidays,&quot; and we look forward to making the web even more social with you in 2009!</body>
611
+ <created_time>1230000042</created_time>
612
+ <attachment>
613
+ <media list="true"/>
614
+ <name>Feb 10, 2010 1:26pm</name>
615
+ <href>http://www.facebook.com/video/video.php?v=12345</href>
616
+ <properties list="true"/>
617
+ <icon>http://static.ak.fbcdn.net/rsrc.php/zB010/hash/9yvl71tw.gif</icon>
618
+ <fb_object_type/>
619
+ <fb_object_id/>
620
+ <tagged_ids list="true"/>
621
+ </attachment>
622
+ <thread_id>1012985167472</thread_id>
623
+ </message>
624
+ </messages>
625
+ </thread>
626
+ </message_getThreadsInFolder_response>
627
+ XML
628
+ end
629
+
449
630
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebooker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.62
4
+ version: 1.0.63
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Fowler
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-02-05 00:00:00 -05:00
17
+ date: 2010-02-22 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -142,6 +142,7 @@ files:
142
142
  - lib/facebooker/models/user.rb
143
143
  - lib/facebooker/models/video.rb
144
144
  - lib/facebooker/models/work_info.rb
145
+ - lib/facebooker/models/message_thread.rb
145
146
  - lib/facebooker/parser.rb
146
147
  - lib/facebooker/rails/backwards_compatible_param_checks.rb
147
148
  - lib/facebooker/rails/controller.rb