facebooker 1.0.63 → 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.
- data/Manifest.txt +1 -0
- data/facebooker.gemspec +3 -3
- data/lib/facebooker.rb +1 -0
- data/lib/facebooker/application.rb +24 -0
- data/lib/facebooker/models/comment.rb +9 -0
- data/lib/facebooker/models/user.rb +140 -0
- data/lib/facebooker/parser.rb +239 -3
- data/lib/facebooker/session.rb +37 -0
- data/lib/facebooker/version.rb +1 -1
- data/test/facebooker/application_test.rb +69 -0
- data/test/facebooker/models/user_test.rb +431 -1
- data/test/facebooker/rails_integration_test.rb +1 -0
- data/test/facebooker_test.rb +224 -0
- metadata +3 -2
data/Manifest.txt
CHANGED
|
@@ -63,6 +63,7 @@ lib/facebooker/models/album.rb
|
|
|
63
63
|
lib/facebooker/models/applicationproperties.rb
|
|
64
64
|
lib/facebooker/models/applicationrestrictions.rb
|
|
65
65
|
lib/facebooker/models/cookie.rb
|
|
66
|
+
lib/facebooker/models/comment.rb
|
|
66
67
|
lib/facebooker/models/education_info.rb
|
|
67
68
|
lib/facebooker/models/event.rb
|
|
68
69
|
lib/facebooker/models/family_relative_info.rb
|
data/facebooker.gemspec
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = %q{facebooker}
|
|
5
|
-
s.version = "1.0.
|
|
5
|
+
s.version = "1.0.64"
|
|
6
6
|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
8
|
s.authors = ["Chad Fowler", "Patrick Ewing", "Mike Mangino", "Shane Vitarana", "Corey Innis", "Mike Mangino"]
|
|
9
|
-
s.date = %q{2010-02-
|
|
9
|
+
s.date = %q{2010-02-26}
|
|
10
10
|
s.description = %q{Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]. Its goals are:
|
|
11
11
|
|
|
12
12
|
* Idiomatic Ruby
|
|
@@ -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/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"]
|
|
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/comment.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
|
@@ -238,6 +238,7 @@ require 'facebooker/version'
|
|
|
238
238
|
require 'facebooker/models/location'
|
|
239
239
|
require 'facebooker/models/affiliation'
|
|
240
240
|
require 'facebooker/models/album'
|
|
241
|
+
require 'facebooker/models/comment'
|
|
241
242
|
require 'facebooker/models/education_info'
|
|
242
243
|
require 'facebooker/models/work_info'
|
|
243
244
|
require 'facebooker/models/event'
|
|
@@ -9,5 +9,29 @@ module Facebooker
|
|
|
9
9
|
def get_public_info(properties)
|
|
10
10
|
(@session.post 'facebook.application.getPublicInfo', properties)
|
|
11
11
|
end
|
|
12
|
+
|
|
13
|
+
# facebook_session.application.add_global_news [{ :message => 'Hi all users', :action_link => { :text => "Hi application", :href => 'http://facebook.er/' }}], 'http://facebook.er/icon.png'
|
|
14
|
+
def add_global_news(news, image=nil)
|
|
15
|
+
params = {}
|
|
16
|
+
params[:news] = news
|
|
17
|
+
params[:image] = image if image
|
|
18
|
+
@session.post('facebook.dashboard.addGlobalNews', params)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# currently bugged on Facebook; returns all
|
|
22
|
+
# facebook_session.application.get_global_news '310354202543'
|
|
23
|
+
def get_global_news(*news_ids)
|
|
24
|
+
params = {}
|
|
25
|
+
params[:news_ids] = news_ids.flatten if news_ids
|
|
26
|
+
@session.post('facebook.dashboard.getGlobalNews', params)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# facebook_session.application.clear_global_news '310354202543'
|
|
30
|
+
def clear_global_news(*news_ids)
|
|
31
|
+
params = {}
|
|
32
|
+
params[:news_ids] = news_ids.flatten if news_ids
|
|
33
|
+
@session.post('facebook.dashboard.clearGlobalNews', params)
|
|
34
|
+
end
|
|
35
|
+
|
|
12
36
|
end
|
|
13
37
|
end
|
|
@@ -185,6 +185,18 @@ module Facebooker
|
|
|
185
185
|
@session.post('facebook.stream.addComment', {:post_id=>post_id, :comment=>comment})
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
+
|
|
189
|
+
###
|
|
190
|
+
# Publish a comment to a specific comment set by xid
|
|
191
|
+
#
|
|
192
|
+
# See: http://wiki.developers.facebook.com/index.php/Comments.add
|
|
193
|
+
#
|
|
194
|
+
# +xid+ the xid for the set of comments
|
|
195
|
+
# +text+ the text of the comment
|
|
196
|
+
def add_comment(xid, text,title=nil,url=nil,publish_to_stream=false)
|
|
197
|
+
@session.post('facebook.comments.add',{:xid=>xid,:text=>text,:title=>title,:url=>url,:publish_to_stream=>publish_to_stream})
|
|
198
|
+
end
|
|
199
|
+
|
|
188
200
|
###
|
|
189
201
|
# Add a like on a post
|
|
190
202
|
#
|
|
@@ -442,6 +454,12 @@ module Facebooker
|
|
|
442
454
|
session.post('facebook.users.hasAppPermission', {:ext_perm=>ext_perm, :uid => uid}, false) == "1"
|
|
443
455
|
end
|
|
444
456
|
|
|
457
|
+
##
|
|
458
|
+
# Returns whether the user (either the session user or user specified by uid) has authorized the calling application
|
|
459
|
+
def app_user?
|
|
460
|
+
session.post('facebook.users.isAppUser', {:uid => self.id}, use_session_key = true)
|
|
461
|
+
end
|
|
462
|
+
|
|
445
463
|
##
|
|
446
464
|
# Convenience method to check multiple permissions at once
|
|
447
465
|
def has_permissions?(ext_perms)
|
|
@@ -475,7 +493,129 @@ module Facebooker
|
|
|
475
493
|
def to_s
|
|
476
494
|
id.to_s
|
|
477
495
|
end
|
|
496
|
+
|
|
497
|
+
|
|
498
|
+
### NEW DASHBOARD API STUFF
|
|
499
|
+
|
|
500
|
+
# facebook_session.user.dashboard_count
|
|
501
|
+
def dashboard_count
|
|
502
|
+
session.post('facebook.dashboard.getCount', :uid => uid)
|
|
503
|
+
end
|
|
504
|
+
|
|
505
|
+
# facebook_session.user.dashboard_count = 5
|
|
506
|
+
def dashboard_count=(new_count)
|
|
507
|
+
session.post('facebook.dashboard.setCount', :uid => uid, :count => new_count)
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
# facebook_session.user.dashboard_increment_count
|
|
511
|
+
def dashboard_increment_count
|
|
512
|
+
session.post('facebook.dashboard.incrementCount', :uid => uid)
|
|
513
|
+
end
|
|
514
|
+
|
|
515
|
+
# facebook_session.user.dashboard_decrement_count
|
|
516
|
+
def dashboard_decrement_count
|
|
517
|
+
session.post('facebook.dashboard.decrementCount', :uid => uid)
|
|
518
|
+
end
|
|
519
|
+
|
|
520
|
+
# The following methods are not bound to a specific user but do relate to Users in general,
|
|
521
|
+
# so I've made them into class methods.
|
|
522
|
+
|
|
523
|
+
# Facebooker::User.dashboard_multi_get_count ['1234', '5678']
|
|
524
|
+
def self.dashboard_multi_get_count(*uids)
|
|
525
|
+
Facebooker::Session.create.post("facebook.dashboard.multiGetCount", :uids => uids.flatten)
|
|
526
|
+
end
|
|
527
|
+
|
|
528
|
+
# Facebooker::User.dashboard_multi_set_count({ '1234' => '11', '5678' => '22' })
|
|
529
|
+
def self.dashboard_multi_set_count(ids)
|
|
530
|
+
Facebooker::Session.create.post("facebook.dashboard.multiSetCount", :ids => ids.to_json)
|
|
531
|
+
end
|
|
532
|
+
|
|
533
|
+
# Facebooker::User.dashboard_multi_increment_count ['1234', '5678']
|
|
534
|
+
def self.dashboard_multi_increment_count(*uids)
|
|
535
|
+
Facebooker::Session.create.post("facebook.dashboard.multiIncrementCount", :uids => uids.flatten.to_json)
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
# Facebooker::User.dashboard_multi_decrement_count ['1234', '5678']
|
|
539
|
+
def self.dashboard_multi_decrement_count(*uids)
|
|
540
|
+
Facebooker::Session.create.post("facebook.dashboard.multiDecrementCount", :uids => uids.flatten.to_json)
|
|
541
|
+
end
|
|
542
|
+
|
|
543
|
+
def self.dashboard_multi_set_count(ids)
|
|
544
|
+
Facebooker::Session.create.post("facebook.dashboard.multiSetCount", :ids => ids.to_json)
|
|
545
|
+
end
|
|
546
|
+
|
|
547
|
+
def self.dashboard_multi_increment_count(uids)
|
|
548
|
+
Facebooker::Session.create.post("facebook.dashboard.multiIncrementCount", :uids => uids.to_json)
|
|
549
|
+
end
|
|
550
|
+
|
|
551
|
+
def self.dashboard_multi_decrement_count(uids)
|
|
552
|
+
Facebooker::Session.create.post("facebook.dashboard.multiDecrementCount", :uids => uids.to_json)
|
|
553
|
+
end
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
|
|
558
|
+
def get_news(*news_ids)
|
|
559
|
+
params = { :uid => uid }
|
|
560
|
+
params[:news_ids] = news_ids.flatten if news_ids
|
|
561
|
+
|
|
562
|
+
session.post('facebook.dashboard.getNews', params)
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
# facebook_session.user.add_news [{ :message => 'Hey, who are you?', :action_link => { :text => "I-I'm a test user", :href => 'http://facebook.er/' }}], 'http://facebook.er/icon.png'
|
|
566
|
+
def add_news(news, image=nil)
|
|
567
|
+
params = { :uid => uid }
|
|
568
|
+
params[:news] = news
|
|
569
|
+
params[:image] = image if image
|
|
570
|
+
|
|
571
|
+
session.post('facebook.dashboard.addNews', params)
|
|
572
|
+
end
|
|
573
|
+
|
|
574
|
+
# facebook_session.user.clear_news ['111111']
|
|
575
|
+
def clear_news(*news_ids)
|
|
576
|
+
params = { :uid => uid }
|
|
577
|
+
params[:news_ids] = news_ids.flatten if news_ids
|
|
578
|
+
|
|
579
|
+
session.post('facebook.dashboard.clearNews', params)
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
# Facebooker::User.multi_add_news(['1234', '4321'], [{ :message => 'Hi users', :action_link => { :text => "Uh hey there app", :href => 'http://facebook.er/' }}], 'http://facebook.er/icon.png')
|
|
583
|
+
def self.multi_add_news(uids, news, image=nil)
|
|
584
|
+
params = { :uids => uids, :news => news }
|
|
585
|
+
params[:image] = image if image
|
|
478
586
|
|
|
587
|
+
Facebooker::Session.create.post("facebook.dashboard.multiAddNews", params)
|
|
588
|
+
end
|
|
589
|
+
|
|
590
|
+
# Facebooker::User.multi_clear_news({"1234"=>["319103117527"], "4321"=>["313954287803"]})
|
|
591
|
+
def self.multi_clear_news(ids)
|
|
592
|
+
Facebooker::Session.create.post("facebook.dashboard.multiClearNews", :ids => ids.to_json)
|
|
593
|
+
end
|
|
594
|
+
|
|
595
|
+
# Facebooker::User.multi_get_news({"1234"=>["319103117527"], "4321"=>["313954287803"]})
|
|
596
|
+
def self.multi_get_news(ids)
|
|
597
|
+
Facebooker::Session.create.post('facebook.dashboard.multiGetNews', :ids => ids.to_json)
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
# facebook_session.user.get_activity '123'
|
|
601
|
+
def get_activity(*activity_ids)
|
|
602
|
+
params = {}
|
|
603
|
+
params[:activity_ids] = activity_ids.flatten if activity_ids
|
|
604
|
+
|
|
605
|
+
session.post('facebook.dashboard.getActivity', params)
|
|
606
|
+
end
|
|
607
|
+
|
|
608
|
+
# facebook_session.user.publish_activity({ :message => '{*actor*} rolled around', :action_link => { :text => 'Roll around too', :href => 'http://facebook.er/' }})
|
|
609
|
+
def publish_activity(activity)
|
|
610
|
+
session.post('facebook.dashboard.publishActivity', { :activity => activity.to_json })
|
|
611
|
+
end
|
|
612
|
+
|
|
613
|
+
# facebook_session.user.remove_activity ['123']
|
|
614
|
+
def remove_activity(*activity_ids)
|
|
615
|
+
session.post('facebook.dashboard.removeActivity', { :activity_ids => activity_ids.flatten })
|
|
616
|
+
end
|
|
617
|
+
|
|
618
|
+
|
|
479
619
|
##
|
|
480
620
|
# Two Facebooker::User objects should be considered equal if their Facebook ids are equal
|
|
481
621
|
def ==(other_user)
|
data/lib/facebooker/parser.rb
CHANGED
|
@@ -79,7 +79,7 @@ module Facebooker
|
|
|
79
79
|
end
|
|
80
80
|
raise "Element #{name} not found in #{data}"
|
|
81
81
|
end
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
def self.hash_or_value_for(element)
|
|
84
84
|
if element.children.size == 1 && element.children.first.text?
|
|
85
85
|
element.content.strip
|
|
@@ -108,6 +108,43 @@ module Facebooker
|
|
|
108
108
|
hash
|
|
109
109
|
end #do |hash, child|
|
|
110
110
|
end
|
|
111
|
+
|
|
112
|
+
def self.hash_by_key_or_value_for(element)
|
|
113
|
+
if element.children.size == 0
|
|
114
|
+
{ element['key'] => nil }
|
|
115
|
+
elsif element.children.size == 1 && element.children.first.text?
|
|
116
|
+
{ element['key'] => element.content.strip }
|
|
117
|
+
else
|
|
118
|
+
hashinate_by_key(element)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# A modification to hashinate. The new dashboard API returns XML in a different format than
|
|
123
|
+
# the other calls. What used to be the element name has become an attribute called "key".
|
|
124
|
+
def self.hashinate_by_key(response_element)
|
|
125
|
+
response_element.children.reject{|c| c.text? }.inject({}) do |hash, child|
|
|
126
|
+
# If the node hasn't any child, and is not a list, we want empty strings, not empty hashes,
|
|
127
|
+
# except if attributes['nil'] == true
|
|
128
|
+
hash[child['key']] =
|
|
129
|
+
if (child['nil'] == 'true')
|
|
130
|
+
nil
|
|
131
|
+
elsif (child.children.size == 1 && child.children.first.text?) || (child.children.size == 0 && child['list'] != 'true')
|
|
132
|
+
anonymous_field_from(child, hash) || child.content.strip
|
|
133
|
+
elsif child['list'] == 'true' && child.children.all? { |subchild| subchild['key'].nil? }
|
|
134
|
+
child.children.reject{|c| c.text? }.map { |subchild| hash_by_key_or_value_for(subchild)}
|
|
135
|
+
elsif child['list'] == 'true'
|
|
136
|
+
hash_by_key_or_value_for(child)
|
|
137
|
+
else
|
|
138
|
+
child.children.reject{|c| c.text? }.inject({}) do |subhash, subchild|
|
|
139
|
+
subhash[subchild['key']] = hash_by_key_or_value_for(subchild)
|
|
140
|
+
subhash
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
hash
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
|
|
111
148
|
|
|
112
149
|
def self.booleanize(response)
|
|
113
150
|
response == "1" ? true : false
|
|
@@ -157,6 +194,12 @@ module Facebooker
|
|
|
157
194
|
end
|
|
158
195
|
end
|
|
159
196
|
|
|
197
|
+
class IsAppUser < Parser#:nodoc:
|
|
198
|
+
def self.process(data)
|
|
199
|
+
element('users_isAppUser_response', data).content == '1'
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
160
203
|
class GetFriends < Parser#:nodoc:
|
|
161
204
|
def self.process(data)
|
|
162
205
|
array_of_text_values(element('friends_get_response', data), 'uid')
|
|
@@ -301,6 +344,24 @@ module Facebooker
|
|
|
301
344
|
end
|
|
302
345
|
end
|
|
303
346
|
|
|
347
|
+
class CommentsAdd < Parser#:nodoc:
|
|
348
|
+
def self.process(data)
|
|
349
|
+
element('comments_add_response', data).content.strip
|
|
350
|
+
end
|
|
351
|
+
end
|
|
352
|
+
|
|
353
|
+
class CommentsRemove < Parser#:nodoc:
|
|
354
|
+
def self.process(data)
|
|
355
|
+
booleanize(data)
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
class CommentsGet < Parser#:nodoc:
|
|
360
|
+
def self.process(data)
|
|
361
|
+
array_of_hashes(element('comments_get_response', data), 'comment')
|
|
362
|
+
end
|
|
363
|
+
end
|
|
364
|
+
|
|
304
365
|
class BatchRun < Parser #:nodoc:
|
|
305
366
|
class << self
|
|
306
367
|
def current_batch=(current_batch)
|
|
@@ -378,6 +439,16 @@ module Facebooker
|
|
|
378
439
|
end
|
|
379
440
|
end
|
|
380
441
|
|
|
442
|
+
class GetStream < Parser #:nodoc:
|
|
443
|
+
def self.process(data)
|
|
444
|
+
response = {}
|
|
445
|
+
response[:albums] = array_of_hashes(element('stream_get_response/albums', data), 'album')
|
|
446
|
+
response[:posts] = array_of_hashes(element('stream_get_response/posts', data), 'stream_post')
|
|
447
|
+
response[:profile] = array_of_hashes(element('stream_get_response/profiles', data), 'profile')
|
|
448
|
+
response
|
|
449
|
+
end
|
|
450
|
+
end
|
|
451
|
+
|
|
381
452
|
class CreateAlbum < Parser#:nodoc:
|
|
382
453
|
def self.process(data)
|
|
383
454
|
hashinate(element('photos_createAlbum_response', data))
|
|
@@ -548,7 +619,7 @@ module Facebooker
|
|
|
548
619
|
end
|
|
549
620
|
end
|
|
550
621
|
|
|
551
|
-
|
|
622
|
+
private
|
|
552
623
|
def self.are_friends?(raw_value)
|
|
553
624
|
if raw_value == '1'
|
|
554
625
|
true
|
|
@@ -602,6 +673,146 @@ module Facebooker
|
|
|
602
673
|
end
|
|
603
674
|
end
|
|
604
675
|
|
|
676
|
+
class DashboardGetCount < Parser
|
|
677
|
+
def self.process(data)
|
|
678
|
+
element('dashboard_getCount_response', data).content.strip
|
|
679
|
+
end
|
|
680
|
+
end
|
|
681
|
+
|
|
682
|
+
class DashboardSetCount < Parser
|
|
683
|
+
def self.process(data)
|
|
684
|
+
element('dashboard_setCount_response', data).content.strip == '1'
|
|
685
|
+
end
|
|
686
|
+
end
|
|
687
|
+
|
|
688
|
+
class DashboardIncrementCount < Parser
|
|
689
|
+
def self.process(data)
|
|
690
|
+
element('dashboard_incrementCount_response', data).content.strip == '1'
|
|
691
|
+
end
|
|
692
|
+
end
|
|
693
|
+
|
|
694
|
+
class DashboardDecrementCount < Parser
|
|
695
|
+
def self.process(data)
|
|
696
|
+
element('dashboard_decrementCount_response', data).content.strip == '1'
|
|
697
|
+
end
|
|
698
|
+
end
|
|
699
|
+
|
|
700
|
+
class DashboardMultiGetCount < Parser
|
|
701
|
+
def self.process(data)
|
|
702
|
+
hashinate_by_key(element('dashboard_multiGetCount_response', data))
|
|
703
|
+
end
|
|
704
|
+
end
|
|
705
|
+
|
|
706
|
+
class DashboardMultiSetCount < Parser
|
|
707
|
+
def self.process(data)
|
|
708
|
+
hashinate_by_key(element('dashboard_multiSetCount_response', data))
|
|
709
|
+
end
|
|
710
|
+
end
|
|
711
|
+
|
|
712
|
+
class DashboardMultiIncrementCount < Parser
|
|
713
|
+
def self.process(data)
|
|
714
|
+
hashinate_by_key(element('dashboard_multiIncrementCount_response', data))
|
|
715
|
+
end
|
|
716
|
+
end
|
|
717
|
+
|
|
718
|
+
class DashboardMultiDecrementCount < Parser
|
|
719
|
+
def self.process(data)
|
|
720
|
+
hashinate_by_key(element('dashboard_multiDecrementCount_response', data))
|
|
721
|
+
end
|
|
722
|
+
end
|
|
723
|
+
|
|
724
|
+
class DashboardMultiSetCount < Parser
|
|
725
|
+
def self.process(data)
|
|
726
|
+
hashinate_by_key(element('dashboard_multiSetCount_response', data))
|
|
727
|
+
end
|
|
728
|
+
end
|
|
729
|
+
|
|
730
|
+
class DashboardMultiIncrementCount < Parser
|
|
731
|
+
def self.process(data)
|
|
732
|
+
hashinate_by_key(element('dashboard_multiIncrementCount_response', data))
|
|
733
|
+
end
|
|
734
|
+
end
|
|
735
|
+
|
|
736
|
+
class DashboardMultiDecrementCount < Parser
|
|
737
|
+
def self.process(data)
|
|
738
|
+
hashinate_by_key(element('dashboard_multiDecrementCount_response', data))
|
|
739
|
+
end
|
|
740
|
+
end
|
|
741
|
+
|
|
742
|
+
class DashboardAddGlobalNews < Parser
|
|
743
|
+
def self.process(data)
|
|
744
|
+
element('dashboard_addGlobalNews_response', data).content.strip
|
|
745
|
+
end
|
|
746
|
+
end
|
|
747
|
+
|
|
748
|
+
# Currently, always returns all
|
|
749
|
+
class DashboardGetGlobalNews < Parser
|
|
750
|
+
def self.process(data)
|
|
751
|
+
hashinate_by_key(element('dashboard_getGlobalNews_response', data))
|
|
752
|
+
end
|
|
753
|
+
end
|
|
754
|
+
|
|
755
|
+
class DashboardClearGlobalNews < Parser
|
|
756
|
+
def self.process(data)
|
|
757
|
+
hashinate_by_key(element('dashboard_clearGlobalNews_response', data))
|
|
758
|
+
end
|
|
759
|
+
end
|
|
760
|
+
|
|
761
|
+
class DashboardAddNews < Parser
|
|
762
|
+
def self.process(data)
|
|
763
|
+
element('dashboard_addNews_response', data).content.strip
|
|
764
|
+
end
|
|
765
|
+
end
|
|
766
|
+
|
|
767
|
+
class DashboardGetNews < Parser
|
|
768
|
+
def self.process(data)
|
|
769
|
+
hashinate_by_key(element('dashboard_getNews_response', data))
|
|
770
|
+
end
|
|
771
|
+
end
|
|
772
|
+
|
|
773
|
+
class DashboardClearNews < Parser
|
|
774
|
+
def self.process(data)
|
|
775
|
+
hashinate_by_key(element('dashboard_clearNews_response', data))
|
|
776
|
+
end
|
|
777
|
+
end
|
|
778
|
+
|
|
779
|
+
class DashboardMultiAddNews < Parser
|
|
780
|
+
def self.process(data)
|
|
781
|
+
hashinate_by_key(element('dashboard_multiAddNews_response', data))
|
|
782
|
+
end
|
|
783
|
+
end
|
|
784
|
+
|
|
785
|
+
class DashboardMultiClearNews < Parser
|
|
786
|
+
def self.process(data)
|
|
787
|
+
hashinate_by_key(element('dashboard_multiClearNews_response', data))
|
|
788
|
+
end
|
|
789
|
+
end
|
|
790
|
+
|
|
791
|
+
class DashboardMultiGetNews < Parser
|
|
792
|
+
def self.process(data)
|
|
793
|
+
hashinate_by_key(element('dashboard_multiGetNews_response', data))
|
|
794
|
+
end
|
|
795
|
+
end
|
|
796
|
+
|
|
797
|
+
class DashboardPublishActivity < Parser
|
|
798
|
+
def self.process(data)
|
|
799
|
+
element('dashboard_publishActivity_response', data).content.strip
|
|
800
|
+
end
|
|
801
|
+
end
|
|
802
|
+
|
|
803
|
+
class DashboardRemoveActivity < Parser
|
|
804
|
+
def self.process(data)
|
|
805
|
+
hashinate_by_key(element('dashboard_removeActivity_response', data))
|
|
806
|
+
end
|
|
807
|
+
end
|
|
808
|
+
|
|
809
|
+
class DashboardGetActivity < Parser
|
|
810
|
+
def self.process(data)
|
|
811
|
+
hashinate_by_key(element('dashboard_getActivity_response', data))
|
|
812
|
+
end
|
|
813
|
+
end
|
|
814
|
+
|
|
815
|
+
|
|
605
816
|
class Errors < Parser#:nodoc:
|
|
606
817
|
EXCEPTIONS = {
|
|
607
818
|
1 => Facebooker::Session::UnknownError,
|
|
@@ -669,6 +880,7 @@ module Facebooker
|
|
|
669
880
|
'facebook.status.get' => GetStatus,
|
|
670
881
|
'facebook.users.getLoggedInUser' => GetLoggedInUser,
|
|
671
882
|
'facebook.users.hasAppPermission' => UserHasPermission,
|
|
883
|
+
'facebook.users.isAppUser' => IsAppUser,
|
|
672
884
|
'facebook.pages.isAdmin' => PagesIsAdmin,
|
|
673
885
|
'facebook.pages.getInfo' => PagesGetInfo,
|
|
674
886
|
'facebook.pages.isFan' => PagesIsFan,
|
|
@@ -711,6 +923,7 @@ module Facebooker
|
|
|
711
923
|
'facebook.photos.getTags' => GetTags,
|
|
712
924
|
'facebook.photos.addTag' => AddTags,
|
|
713
925
|
'facebook.photos.upload' => UploadPhoto,
|
|
926
|
+
'facebook.stream.get' => GetStream,
|
|
714
927
|
'facebook.stream.publish' => StreamPublish,
|
|
715
928
|
'facebook.stream.addComment' => StreamAddComment,
|
|
716
929
|
'facebook.stream.addLike' => StreamAddLike,
|
|
@@ -726,7 +939,30 @@ module Facebooker
|
|
|
726
939
|
'facebook.data.setUserPreference' => SetPreference,
|
|
727
940
|
'facebook.video.upload' => UploadVideo,
|
|
728
941
|
'facebook.sms.send' => SmsSend,
|
|
729
|
-
'facebook.sms.canSend' => SmsCanSend
|
|
942
|
+
'facebook.sms.canSend' => SmsCanSend,
|
|
943
|
+
'facebook.comments.add' => CommentsAdd,
|
|
944
|
+
'facebook.comments.remove' => CommentsRemove,
|
|
945
|
+
'facebook.comments.get' => CommentsGet,
|
|
946
|
+
'facebook.dashboard.setCount' => DashboardSetCount,
|
|
947
|
+
'facebook.dashboard.getCount' => DashboardGetCount,
|
|
948
|
+
'facebook.dashboard.incrementCount' => DashboardIncrementCount,
|
|
949
|
+
'facebook.dashboard.decrementCount' => DashboardDecrementCount,
|
|
950
|
+
'facebook.dashboard.multiGetCount' => DashboardMultiGetCount,
|
|
951
|
+
'facebook.dashboard.multiSetCount' => DashboardMultiSetCount,
|
|
952
|
+
'facebook.dashboard.multiIncrementCount' => DashboardMultiIncrementCount,
|
|
953
|
+
'facebook.dashboard.multiDecrementCount' => DashboardMultiDecrementCount,
|
|
954
|
+
'facebook.dashboard.addGlobalNews' => DashboardAddGlobalNews,
|
|
955
|
+
'facebook.dashboard.getGlobalNews' => DashboardGetGlobalNews,
|
|
956
|
+
'facebook.dashboard.clearGlobalNews' => DashboardClearGlobalNews,
|
|
957
|
+
'facebook.dashboard.addNews' => DashboardAddNews,
|
|
958
|
+
'facebook.dashboard.getNews' => DashboardGetNews,
|
|
959
|
+
'facebook.dashboard.clearNews' => DashboardClearNews,
|
|
960
|
+
'facebook.dashboard.multiAddNews' => DashboardMultiAddNews,
|
|
961
|
+
'facebook.dashboard.multiGetNews' => DashboardMultiGetNews,
|
|
962
|
+
'facebook.dashboard.multiClearNews' => DashboardMultiClearNews,
|
|
963
|
+
'facebook.dashboard.publishActivity' => DashboardPublishActivity,
|
|
964
|
+
'facebook.dashboard.removeActivity' => DashboardRemoveActivity,
|
|
965
|
+
'facebook.dashboard.getActivity' => DashboardGetActivity
|
|
730
966
|
}
|
|
731
967
|
end
|
|
732
968
|
end
|