facebooker 1.0.58 → 1.0.59
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +3 -0
- data/README.rdoc +6 -0
- data/facebooker.gemspec +8 -8
- data/lib/facebooker/models/user.rb +9 -0
- data/lib/facebooker/parser.rb +7 -0
- data/lib/facebooker/rails/controller.rb +3 -6
- data/lib/facebooker/rails/extensions/rack_setup.rb +8 -0
- data/lib/facebooker/rails/helpers.rb +15 -8
- data/lib/facebooker/rails/publisher.rb +1 -0
- data/lib/facebooker/session.rb +1 -0
- data/lib/facebooker/version.rb +1 -1
- data/lib/rack/facebook_session.rb +21 -0
- data/lib/tasks/facebooker.rb +2 -0
- data/test/facebooker/models/user_test.rb +13 -0
- data/test/facebooker/rails_integration_test.rb +3 -5
- data/test/rack/facebook_session_test.rb +34 -0
- data/test/test_helper.rb +1 -1
- metadata +8 -4
data/Manifest.txt
CHANGED
@@ -113,7 +113,9 @@ lib/facebooker/stream_post.rb
|
|
113
113
|
lib/facebooker/version.rb
|
114
114
|
lib/net/http_multipart_post.rb
|
115
115
|
lib/rack/facebook.rb
|
116
|
+
lib/rack/facebook_session.rb
|
116
117
|
lib/tasks/facebooker.rake
|
118
|
+
lib/tasks/facebooker.rb
|
117
119
|
lib/tasks/tunnel.rake
|
118
120
|
rails/init.rb
|
119
121
|
setup.rb
|
@@ -142,5 +144,6 @@ test/fixtures/multipart_post_body_with_single_file.txt
|
|
142
144
|
test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt
|
143
145
|
test/net/http_multipart_post_test.rb
|
144
146
|
test/rack/facebook_test.rb
|
147
|
+
test/rack/facebook_session_test.rb
|
145
148
|
test/rails_test_helper.rb
|
146
149
|
test/test_helper.rb
|
data/README.rdoc
CHANGED
@@ -48,6 +48,12 @@ Facebooker can be installed as a Rails plugin by:
|
|
48
48
|
|
49
49
|
If you don't have git, the plugin can be downloaded from http://github.com/mmangino/facebooker/tarball/master
|
50
50
|
|
51
|
+
=== Using Gem in Rails
|
52
|
+
|
53
|
+
The rake task would not be added automatically, so to use it in rails you would have to add the following towards the end of your Rakefile:
|
54
|
+
|
55
|
+
require 'tasks/facebooker'
|
56
|
+
|
51
57
|
Once the plugin is installed, you will need to configure your Facebook app in config/facebooker.yml.
|
52
58
|
|
53
59
|
Your application users will need to have added the application in facebook to access all of facebooker's features. You enforce this by adding
|
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.59"
|
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{
|
9
|
+
s.date = %q{2010-01-15}
|
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,14 +15,14 @@ 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/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/tasks/facebooker.rake", "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/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/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/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"]
|
22
22
|
s.rubyforge_project = %q{facebooker}
|
23
|
-
s.rubygems_version = %q{1.3.
|
23
|
+
s.rubygems_version = %q{1.3.5}
|
24
24
|
s.summary = %q{Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]}
|
25
|
-
s.test_files = ["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/facebook_request_fix_2-3_test.rb", "test/facebooker/rails/facebook_url_rewriting_test.rb", "test/facebooker/rails/integration_session_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/service_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/net/http_multipart_post_test.rb", "test/rack/facebook_test.rb"]
|
25
|
+
s.test_files = ["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/facebook_request_fix_2-3_test.rb", "test/facebooker/rails/facebook_url_rewriting_test.rb", "test/facebooker/rails/integration_session_test.rb", "test/facebooker/rails/publisher_test.rb", "test/facebooker/rails_integration_test.rb", "test/facebooker/server_cache_test.rb", "test/facebooker/service_test.rb", "test/facebooker/session_test.rb", "test/facebooker_test.rb", "test/net/http_multipart_post_test.rb", "test/rack/facebook_session_test.rb", "test/rack/facebook_test.rb"]
|
26
26
|
|
27
27
|
if s.respond_to? :specification_version then
|
28
28
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
@@ -30,13 +30,13 @@ Gem::Specification.new do |s|
|
|
30
30
|
|
31
31
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
32
32
|
s.add_runtime_dependency(%q<json>, [">= 1.0.0"])
|
33
|
-
s.add_development_dependency(%q<hoe>, [">= 2.
|
33
|
+
s.add_development_dependency(%q<hoe>, [">= 2.4.0"])
|
34
34
|
else
|
35
35
|
s.add_dependency(%q<json>, [">= 1.0.0"])
|
36
|
-
s.add_dependency(%q<hoe>, [">= 2.
|
36
|
+
s.add_dependency(%q<hoe>, [">= 2.4.0"])
|
37
37
|
end
|
38
38
|
else
|
39
39
|
s.add_dependency(%q<json>, [">= 1.0.0"])
|
40
|
-
s.add_dependency(%q<hoe>, [">= 2.
|
40
|
+
s.add_dependency(%q<hoe>, [">= 2.4.0"])
|
41
41
|
end
|
42
42
|
end
|
@@ -183,6 +183,15 @@ module Facebooker
|
|
183
183
|
@session.post('facebook.stream.addComment', {:post_id=>post_id, :comment=>comment})
|
184
184
|
end
|
185
185
|
|
186
|
+
###
|
187
|
+
# Add a like on a post
|
188
|
+
#
|
189
|
+
# See: http://wiki.developers.facebook.com/index.php/Stream.addLike
|
190
|
+
#
|
191
|
+
# +post_id+ the post_id for the post that is being commented on
|
192
|
+
def add_like_on(post_id)
|
193
|
+
@session.post('facebook.stream.addLike', {:post_id=>post_id})
|
194
|
+
end
|
186
195
|
|
187
196
|
def friend_lists
|
188
197
|
@friend_lists ||= @session.post('facebook.friends.getLists').map do |hash|
|
data/lib/facebooker/parser.rb
CHANGED
@@ -223,6 +223,12 @@ module Facebooker
|
|
223
223
|
end
|
224
224
|
end
|
225
225
|
|
226
|
+
class StreamAddLike < Parser#:nodoc:
|
227
|
+
def self.process(data)
|
228
|
+
element('stream_addLike_response', data).content.strip
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
226
232
|
class RegisterTemplateBundle < Parser#:nodoc:
|
227
233
|
def self.process(data)
|
228
234
|
element('feed_registerTemplateBundle_response', data).content.to_i
|
@@ -699,6 +705,7 @@ module Facebooker
|
|
699
705
|
'facebook.photos.upload' => UploadPhoto,
|
700
706
|
'facebook.stream.publish' => StreamPublish,
|
701
707
|
'facebook.stream.addComment' => StreamAddComment,
|
708
|
+
'facebook.stream.addLike' => StreamAddLike,
|
702
709
|
'facebook.events.create' => EventsCreate,
|
703
710
|
'facebook.events.cancel' => EventsCancel,
|
704
711
|
'facebook.events.get' => EventsGet,
|
@@ -131,17 +131,14 @@ module Facebooker
|
|
131
131
|
|
132
132
|
def secure_with_cookies!
|
133
133
|
parsed = {}
|
134
|
-
|
135
|
-
|
136
|
-
# it doesn't happen for me (mmangino)
|
137
|
-
# so force it to array and take the first value
|
138
|
-
fb_cookie_names.each { |key| parsed[key[fb_cookie_prefix.size,key.size]] = Array(cookies[key]).first }
|
134
|
+
|
135
|
+
fb_cookie_names.each { |key| parsed[key[fb_cookie_prefix.size,key.size]] = cookies[key] }
|
139
136
|
|
140
137
|
#returning gracefully if the cookies aren't set or have expired
|
141
138
|
return unless parsed['session_key'] && parsed['user'] && parsed['expires'] && parsed['ss']
|
142
139
|
return unless (Time.at(parsed['expires'].to_s.to_f) > Time.now) || (parsed['expires'] == "0")
|
143
140
|
#if we have the unexpired cookies, we'll throw an exception if the sig doesn't verify
|
144
|
-
verify_signature(parsed,cookies[Facebooker.api_key],true)
|
141
|
+
verify_signature(parsed,cookies[Facebooker.api_key], true)
|
145
142
|
|
146
143
|
@facebook_session = new_facebook_session
|
147
144
|
@facebook_session.secure_with!(parsed['session_key'],parsed['user'],parsed['expires'],parsed['ss'])
|
@@ -1,6 +1,14 @@
|
|
1
1
|
# Somewhere in 2.3 RewindableInput was removed- rack supports it natively
|
2
2
|
require 'rack/facebook'
|
3
|
+
require 'rack/facebook_session'
|
4
|
+
|
3
5
|
ActionController::Dispatcher.middleware.insert_before(
|
4
6
|
ActionController::ParamsParser,
|
5
7
|
Rack::Facebook
|
6
8
|
)
|
9
|
+
|
10
|
+
# ActionController::Dispatcher.middleware.insert_before(
|
11
|
+
# ActionController::Base.session_store,
|
12
|
+
# Rack::FacebookSession,
|
13
|
+
# lambda { ActionController::Base.session_options[:key] }
|
14
|
+
# )
|
@@ -25,6 +25,7 @@ module Facebooker
|
|
25
25
|
# cancel_button is true or false
|
26
26
|
def fb_dialog( id, cancel_button, &block )
|
27
27
|
content = capture(&block)
|
28
|
+
cancel_button = cancel_button ? 1 : 0 unless cancel_button == 0
|
28
29
|
versioned_concat( content_tag("fb:dialog", content, {:id => id, :cancel_button => cancel_button}), block.binding )
|
29
30
|
end
|
30
31
|
|
@@ -107,17 +108,17 @@ module Facebooker
|
|
107
108
|
|
108
109
|
# Create an fb:request-form with an fb_multi_friend_selector inside
|
109
110
|
#
|
110
|
-
# The content of the block are used as the message on the form,
|
111
|
+
# The content of the block are used as the message on the form, the options hash is passed onto fb_multi_friend_selector.
|
111
112
|
#
|
112
113
|
# For example:
|
113
|
-
# <% fb_multi_friend_request("Poke","Choose some friends to Poke",create_poke_path) do %>
|
114
|
+
# <% fb_multi_friend_request("Poke","Choose some friends to Poke",create_poke_path,:exclude_ids => "123456789,987654321") do %>
|
114
115
|
# If you select some friends, they will see this message.
|
115
116
|
# <%= fb_req_choice("They will get this button, too",new_poke_path) %>
|
116
117
|
# <% end %>
|
117
|
-
def fb_multi_friend_request(type,friend_selector_message,url,&block)
|
118
|
+
def fb_multi_friend_request(type,friend_selector_message,url, fb_multi_friend_selector_options = {},&block)
|
118
119
|
content = capture(&block)
|
119
120
|
versioned_concat(content_tag("fb:request-form",
|
120
|
-
fb_multi_friend_selector(friend_selector_message) + token_tag,
|
121
|
+
fb_multi_friend_selector(friend_selector_message, fb_multi_friend_selector_options) + token_tag,
|
121
122
|
{:action=>url,:method=>"post",:invite=>true,:type=>type,:content=>content}
|
122
123
|
),
|
123
124
|
block.binding)
|
@@ -697,8 +698,11 @@ module Facebooker
|
|
697
698
|
# more details
|
698
699
|
def fb_intl(text=nil, options={}, &proc)
|
699
700
|
raise ArgumentError, "Missing block or text" unless block_given? or text
|
700
|
-
|
701
|
-
|
701
|
+
if block_given?
|
702
|
+
versioned_concat(fb_intl(capture(&proc), options))
|
703
|
+
else
|
704
|
+
content_tag("fb:intl", text, stringify_vals(options))
|
705
|
+
end
|
702
706
|
end
|
703
707
|
|
704
708
|
# Renders a fb:intl-token element
|
@@ -710,8 +714,11 @@ module Facebooker
|
|
710
714
|
# more details
|
711
715
|
def fb_intl_token(name, text=nil, &proc)
|
712
716
|
raise ArgumentError, "Missing block or text" unless block_given? or text
|
713
|
-
|
714
|
-
|
717
|
+
if block_given?
|
718
|
+
versioned_concat(fb_intl_token(name, capture(&proc)))
|
719
|
+
else
|
720
|
+
content_tag("fb:intl-token", text, stringify_vals({:name => name}))
|
721
|
+
end
|
715
722
|
end
|
716
723
|
|
717
724
|
# Renders a fb:date element
|
data/lib/facebooker/session.rb
CHANGED
data/lib/facebooker/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rack/request'
|
2
|
+
|
3
|
+
module Rack
|
4
|
+
class FacebookSession
|
5
|
+
|
6
|
+
FACEBOOK_SESSION_KEY = 'fb_sig_session_key'
|
7
|
+
|
8
|
+
def initialize(app, session_key = lambda { '_session_id' })
|
9
|
+
@app = app
|
10
|
+
@session_key = session_key
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
req = Rack::Request.new(env)
|
15
|
+
key = req.POST[FACEBOOK_SESSION_KEY] || req.GET[FACEBOOK_SESSION_KEY]
|
16
|
+
env['HTTP_COOKIE'] = [ @session_key.call, key ].join('=').freeze unless key.nil?
|
17
|
+
|
18
|
+
@app.call(env)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -183,6 +183,12 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
183
183
|
assert_equal('703826862_78463536863', @user.comment_on('703826862_78463536862', :message => 'that was hilarious!'))
|
184
184
|
end
|
185
185
|
|
186
|
+
def test_add_like_on
|
187
|
+
@user = Facebooker::User.new(548871286, @session)
|
188
|
+
expect_http_posts_with_responses(example_add_like_on_response)
|
189
|
+
assert_equal('1', @user.add_like_on('703826862_78463536862'))
|
190
|
+
end
|
191
|
+
|
186
192
|
def test_can_send_email
|
187
193
|
@user.expects(:send_email).with("subject", "body text")
|
188
194
|
@user.send_email("subject", "body text")
|
@@ -405,6 +411,13 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
405
411
|
<stream_addComment_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">703826862_78463536863</stream_addComment_response>
|
406
412
|
eoxml
|
407
413
|
end
|
414
|
+
|
415
|
+
def example_add_like_on_response
|
416
|
+
<<-eoxml
|
417
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
418
|
+
<stream_addLike_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</stream_addLike_response>
|
419
|
+
eoxml
|
420
|
+
end
|
408
421
|
|
409
422
|
def example_events_rsvp_xml
|
410
423
|
<<-E
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../rails_test_helper')
|
|
2
2
|
|
3
3
|
module FBConnectTestHelpers
|
4
4
|
def setup_fb_connect_cookies(params=cookie_hash_for_auth)
|
5
|
-
params.each {|k,v| @request.cookies[ENV['FACEBOOK_API_KEY']+k] = CGI::Cookie.new(ENV['FACEBOOK_API_KEY']+k,v)}
|
5
|
+
params.each {|k,v| @request.cookies[ENV['FACEBOOK_API_KEY']+k] = CGI::Cookie.new(ENV['FACEBOOK_API_KEY']+k,v).first}
|
6
6
|
end
|
7
7
|
|
8
8
|
def expired_cookie_hash_for_auth
|
@@ -171,7 +171,6 @@ class RailsIntegrationTestForFBConnect < Test::Unit::TestCase
|
|
171
171
|
def test_doesnt_set_cookie_but_facebook_session_is_available
|
172
172
|
setup_fb_connect_cookies
|
173
173
|
get :index
|
174
|
-
p "this one"
|
175
174
|
assert_not_nil @controller.facebook_session
|
176
175
|
assert_nil @response.cookies[:facebook_session]
|
177
176
|
|
@@ -884,8 +883,7 @@ class RailsHelperTest < Test::Unit::TestCase
|
|
884
883
|
|
885
884
|
def test_fb_dialog
|
886
885
|
@h.expects(:capture).returns("dialog content")
|
887
|
-
@h.fb_dialog( "my_dialog",
|
888
|
-
end
|
886
|
+
@h.fb_dialog( "my_dialog", true ) {}
|
889
887
|
assert_equal '<fb:dialog cancel_button="1" id="my_dialog">dialog content</fb:dialog>', @h.output_buffer
|
890
888
|
end
|
891
889
|
def test_fb_dialog_title
|
@@ -1124,7 +1122,7 @@ class RailsHelperTest < Test::Unit::TestCase
|
|
1124
1122
|
stream_post.target="12451752"
|
1125
1123
|
stream_post.attachment = attachment
|
1126
1124
|
|
1127
|
-
assert @h.fb_connect_stream_publish(stream_post).match(/FB.Connect\.streamPublish\(\"message\", {\"name\":\s?\"name\"}, \[], \"12451752\", null, null, false, null\);/)
|
1125
|
+
assert @h.fb_connect_stream_publish(stream_post).match(/FB.Connect\.streamPublish\(\"message\", \{\"name\":\s?\"name\"\}, \[\], \"12451752\", null, null, false, null\);/)
|
1128
1126
|
end
|
1129
1127
|
|
1130
1128
|
def test_fb_connect_javascript_tag
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
2
|
+
require 'rack/facebook_session'
|
3
|
+
require 'rack/lint'
|
4
|
+
require 'rack/mock'
|
5
|
+
|
6
|
+
class Rack::FacebookSessionTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@app = lambda do |env|
|
10
|
+
@env = env
|
11
|
+
Rack::Response.new().to_a
|
12
|
+
end
|
13
|
+
|
14
|
+
@facebook = Rack::FacebookSession.new(@app, lambda { '_top_sekrit' })
|
15
|
+
end
|
16
|
+
|
17
|
+
def params(p)
|
18
|
+
p.map{|*args| args.join('=') }.join('&')
|
19
|
+
end
|
20
|
+
|
21
|
+
def app
|
22
|
+
Rack::MockRequest.new(Rack::Lint.new(@facebook))
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_converts_session_key_on_get
|
26
|
+
response = app.get '/', :input => params(:fb_sig_session_key => 'foo')
|
27
|
+
assert_equal '_top_sekrit=foo', @env['HTTP_COOKIE']
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_converts_session_key_on_post
|
31
|
+
response = app.post '/', :input => params(:fb_sig_session_key => 'foo')
|
32
|
+
assert_equal '_top_sekrit=foo', @env['HTTP_COOKIE']
|
33
|
+
end
|
34
|
+
end
|
data/test/test_helper.rb
CHANGED
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.
|
4
|
+
version: 1.0.59
|
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:
|
17
|
+
date: 2010-01-15 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -35,7 +35,7 @@ dependencies:
|
|
35
35
|
requirements:
|
36
36
|
- - ">="
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version: 2.
|
38
|
+
version: 2.4.0
|
39
39
|
version:
|
40
40
|
description: |-
|
41
41
|
Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]. Its goals are:
|
@@ -177,7 +177,9 @@ files:
|
|
177
177
|
- lib/facebooker/version.rb
|
178
178
|
- lib/net/http_multipart_post.rb
|
179
179
|
- lib/rack/facebook.rb
|
180
|
+
- lib/rack/facebook_session.rb
|
180
181
|
- lib/tasks/facebooker.rake
|
182
|
+
- lib/tasks/facebooker.rb
|
181
183
|
- lib/tasks/tunnel.rake
|
182
184
|
- rails/init.rb
|
183
185
|
- setup.rb
|
@@ -206,6 +208,7 @@ files:
|
|
206
208
|
- test/fixtures/multipart_post_body_with_single_file_that_has_nil_key.txt
|
207
209
|
- test/net/http_multipart_post_test.rb
|
208
210
|
- test/rack/facebook_test.rb
|
211
|
+
- test/rack/facebook_session_test.rb
|
209
212
|
- test/rails_test_helper.rb
|
210
213
|
- test/test_helper.rb
|
211
214
|
has_rdoc: true
|
@@ -233,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
233
236
|
requirements: []
|
234
237
|
|
235
238
|
rubyforge_project: facebooker
|
236
|
-
rubygems_version: 1.3.
|
239
|
+
rubygems_version: 1.3.5
|
237
240
|
signing_key:
|
238
241
|
specification_version: 3
|
239
242
|
summary: Facebooker is a Ruby wrapper over the Facebook[http://facebook.com] {REST API}[http://wiki.developers.facebook.com/index.php/API]
|
@@ -261,4 +264,5 @@ test_files:
|
|
261
264
|
- test/facebooker/session_test.rb
|
262
265
|
- test/facebooker_test.rb
|
263
266
|
- test/net/http_multipart_post_test.rb
|
267
|
+
- test/rack/facebook_session_test.rb
|
264
268
|
- test/rack/facebook_test.rb
|