facebooker 1.0.54 → 1.0.55
Sign up to get free protection for your applications and to get access to all the features.
- data/facebooker.gemspec +3 -3
- data/lib/facebooker/models/user.rb +8 -1
- data/lib/facebooker/parser.rb +7 -0
- data/lib/facebooker/rails/facebook_form_builder.rb +33 -4
- data/lib/facebooker/rails/helpers/fb_connect.rb +11 -11
- data/lib/facebooker/session.rb +30 -4
- data/lib/facebooker/version.rb +1 -1
- data/test/facebooker/models/user_test.rb +8 -0
- data/test/facebooker/rails_integration_test.rb +1 -1
- data/test/facebooker/session_test.rb +23 -0
- metadata +2 -2
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.55"
|
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{2009-
|
9
|
+
s.date = %q{2009-11-06}
|
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/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/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/
|
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/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/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/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"]
|
19
19
|
s.homepage = %q{http://facebooker.rubyforge.org}
|
20
20
|
s.rdoc_options = ["--main", "README.rdoc"]
|
21
21
|
s.require_paths = ["lib"]
|
@@ -374,7 +374,14 @@ module Facebooker
|
|
374
374
|
@status = Status.from_hash(message)
|
375
375
|
end
|
376
376
|
end
|
377
|
-
|
377
|
+
|
378
|
+
|
379
|
+
##
|
380
|
+
# Return +limit+ statuses from the user
|
381
|
+
def statuses( limit = 50 )
|
382
|
+
session.post('facebook.status.get', {:uid => uid, :limit => limit}).collect { |ret| Status.from_hash(ret) }
|
383
|
+
end
|
384
|
+
|
378
385
|
##
|
379
386
|
# Set the status for a user
|
380
387
|
# DOES NOT prepend "is" to the message
|
data/lib/facebooker/parser.rb
CHANGED
@@ -554,6 +554,12 @@ module Facebooker
|
|
554
554
|
end
|
555
555
|
end
|
556
556
|
|
557
|
+
class GetStatus < Parser # :nodoc:
|
558
|
+
def self.process(data)
|
559
|
+
array_of_hashes(element('status_get_response',data),'user_status')
|
560
|
+
end
|
561
|
+
end
|
562
|
+
|
557
563
|
class GetPreference < Parser#:nodoc:
|
558
564
|
def self.process(data)
|
559
565
|
element('data_getUserPreference_response', data).content.strip
|
@@ -647,6 +653,7 @@ module Facebooker
|
|
647
653
|
'facebook.users.getInfo' => UserInfo,
|
648
654
|
'facebook.users.getStandardInfo' => UserStandardInfo,
|
649
655
|
'facebook.users.setStatus' => SetStatus,
|
656
|
+
'facebook.status.get' => GetStatus,
|
650
657
|
'facebook.users.getLoggedInUser' => GetLoggedInUser,
|
651
658
|
'facebook.users.hasAppPermission' => UserHasPermission,
|
652
659
|
'facebook.pages.isAdmin' => PagesIsAdmin,
|
@@ -10,7 +10,7 @@ module Facebooker
|
|
10
10
|
def self.create_with_offset(name,offset)
|
11
11
|
define_method name do |field,*args|
|
12
12
|
options = args[offset] || {}
|
13
|
-
build_shell(field,options) do
|
13
|
+
build_shell(field,options.with_indifferent_access) do
|
14
14
|
super
|
15
15
|
end
|
16
16
|
end
|
@@ -42,6 +42,7 @@ module Facebooker
|
|
42
42
|
|
43
43
|
|
44
44
|
def text_field(method, options = {})
|
45
|
+
options = options.with_indifferent_access
|
45
46
|
options[:label] ||= label_for(method,options)
|
46
47
|
add_default_name_and_id(options,method)
|
47
48
|
options["value"] ||= value_before_type_cast(object,method)
|
@@ -102,11 +103,39 @@ module Facebooker
|
|
102
103
|
@template.content_tag("fb:editor-button","",:value=>name,:name=>"commit")
|
103
104
|
end
|
104
105
|
|
105
|
-
def add_default_name_and_id(options,method)
|
106
|
-
|
107
|
-
options
|
106
|
+
def add_default_name_and_id(options, method)
|
107
|
+
@method_name = method
|
108
|
+
if options.has_key?("index")
|
109
|
+
options["name"] ||= tag_name_with_index(options["index"])
|
110
|
+
options["id"] ||= tag_id_with_index(options["index"])
|
111
|
+
options.delete("index")
|
112
|
+
else
|
113
|
+
options["name"] ||= tag_name + (options.has_key?('multiple') ? '[]' : '')
|
114
|
+
options["id"] ||= "#{sanitized_object_name}_#{sanitized_method_name}"
|
115
|
+
end
|
108
116
|
end
|
109
117
|
|
118
|
+
|
119
|
+
private
|
120
|
+
def tag_name
|
121
|
+
"#{@object_name.to_s}[#{sanitized_method_name}]"
|
122
|
+
end
|
123
|
+
|
124
|
+
def tag_name_with_index(index)
|
125
|
+
"#{@object_name.to_s}[#{index}][#{sanitized_method_name}]"
|
126
|
+
end
|
127
|
+
|
128
|
+
def tag_id_with_index(index)
|
129
|
+
"#{sanitized_object_name}_#{index}_#{sanitized_method_name}"
|
130
|
+
end
|
131
|
+
|
132
|
+
def sanitized_object_name
|
133
|
+
@object_name.to_s.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
|
134
|
+
end
|
135
|
+
|
136
|
+
def sanitized_method_name
|
137
|
+
@method_name.to_s.sub(/\?$/,"")
|
138
|
+
end
|
110
139
|
end
|
111
140
|
end
|
112
141
|
end
|
@@ -2,7 +2,7 @@ module Facebooker
|
|
2
2
|
module Rails
|
3
3
|
module Helpers
|
4
4
|
module FbConnect
|
5
|
-
|
5
|
+
|
6
6
|
def fb_connect_javascript_tag(options = {})
|
7
7
|
# accept both Rails and Facebook locale formatting, i.e. "en-US" and "en_US".
|
8
8
|
lang = "/#{options[:lang].to_s.gsub('-', '_')}" if options[:lang]
|
@@ -13,9 +13,9 @@ module Facebooker
|
|
13
13
|
"<script src=\"http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php#{lang}\" type=\"text/javascript\"></script>"
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
17
|
-
#
|
18
|
-
# For information on the :app_settings argument see http://wiki.developers.facebook.com/index.php/JS_API_M_FB.Facebook.Init_2
|
16
|
+
|
17
|
+
#
|
18
|
+
# For information on the :app_settings argument see http://wiki.developers.facebook.com/index.php/JS_API_M_FB.Facebook.Init_2
|
19
19
|
# While it would be nice to treat :app_settings as a hash, some of the arguments do different things if they are a string vs a javascript function
|
20
20
|
# and Rails' Hash#to_json always quotes strings so there is no way to indicate when the value should be a javascript function.
|
21
21
|
# For this reason :app_settings needs to be a string that is valid JSON (including the {}'s).
|
@@ -41,7 +41,7 @@ module Facebooker
|
|
41
41
|
unless required_features.blank?
|
42
42
|
init_string = <<-FBML
|
43
43
|
#{case options[:js]
|
44
|
-
when :jquery then "
|
44
|
+
when :jquery then "jQuery(document).ready("
|
45
45
|
when :dojo then "dojo.addOnLoad("
|
46
46
|
else "Element.observe(window,'load',"
|
47
47
|
end} function() {
|
@@ -64,9 +64,9 @@ module Facebooker
|
|
64
64
|
javascript_tag init_string
|
65
65
|
end
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
# Render an <fb:login-button> element
|
69
|
-
#
|
69
|
+
#
|
70
70
|
# ==== Examples
|
71
71
|
#
|
72
72
|
# <%= fb_login_button%>
|
@@ -97,25 +97,25 @@ module Facebooker
|
|
97
97
|
end
|
98
98
|
content_tag("fb:login-button",nil,options.merge(:onlogin=>js))
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
def fb_unconnected_friends_count
|
102
102
|
content_tag "fb:unconnected-friends-count",nil
|
103
103
|
end
|
104
|
-
|
104
|
+
|
105
105
|
def fb_logout_link(text,url,*args)
|
106
106
|
js = update_page do |page|
|
107
107
|
page.call "FB.Connect.logoutAndRedirect",url
|
108
108
|
end
|
109
109
|
link_to_function text, js, *args
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
def fb_user_action(action, user_message = nil, prompt = "", callback = nil)
|
113
113
|
defaulted_callback = callback || "null"
|
114
114
|
update_page do |page|
|
115
115
|
page.call("FB.Connect.showFeedDialog",action.template_id,action.data,action.target_ids,action.body_general,nil,page.literal("FB.RequireConnect.promptConnect"),page.literal(defaulted_callback),prompt,user_message.nil? ? nil : {:value=>user_message})
|
116
116
|
end
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
end
|
120
120
|
end
|
121
121
|
end
|
data/lib/facebooker/session.rb
CHANGED
@@ -239,9 +239,12 @@ module Facebooker
|
|
239
239
|
def fql_query(query, format = 'XML')
|
240
240
|
post('facebook.fql.query', :query => query, :format => format) do |response|
|
241
241
|
type = response.shift
|
242
|
-
|
243
|
-
|
244
|
-
|
242
|
+
if type.nil?
|
243
|
+
[]
|
244
|
+
else
|
245
|
+
response.shift.map do |hash|
|
246
|
+
fql_build_object(type, hash)
|
247
|
+
end
|
245
248
|
end
|
246
249
|
end
|
247
250
|
end
|
@@ -285,10 +288,33 @@ module Facebooker
|
|
285
288
|
end
|
286
289
|
end
|
287
290
|
|
288
|
-
# Creates an event with the event_info hash and an optional Net::HTTP::MultipartPostFile for the event picture
|
291
|
+
# Creates an event with the event_info hash and an optional Net::HTTP::MultipartPostFile for the event picture.
|
292
|
+
# If ActiveSupport::TimeWithZone is installed (it's in Rails > 2.1), and start_time or end_time are given as
|
293
|
+
# ActiveSupport::TimeWithZone, then they will be assumed to represent local time for the event. They will automatically be
|
294
|
+
# converted to the expected timezone for Facebook, which is PST or PDT depending on when the event occurs.
|
289
295
|
# Returns the eid of the newly created event
|
290
296
|
# http://wiki.developers.facebook.com/index.php/Events.create
|
291
297
|
def create_event(event_info, multipart_post_file = nil)
|
298
|
+
if defined?(ActiveSupport::TimeWithZone) && defined?(ActiveSupport::TimeZone)
|
299
|
+
# Facebook expects all event local times to be in Pacific Time, so we need to take the actual local time and
|
300
|
+
# send it to Facebook as if it were Pacific Time converted to Unix epoch timestamp. Very confusing...
|
301
|
+
facebook_time = ActiveSupport::TimeZone["Pacific Time (US & Canada)"]
|
302
|
+
|
303
|
+
start_time = event_info.delete(:start_time) || event_info.delete('start_time')
|
304
|
+
if start_time && start_time.is_a?(ActiveSupport::TimeWithZone)
|
305
|
+
event_info['start_time'] = facebook_time.parse(start_time.strftime("%Y-%m-%d %H:%M:%S")).to_i
|
306
|
+
else
|
307
|
+
event_info['start_time'] = start_time
|
308
|
+
end
|
309
|
+
|
310
|
+
end_time = event_info.delete(:end_time) || event_info.delete('end_time')
|
311
|
+
if end_time && end_time.is_a?(ActiveSupport::TimeWithZone)
|
312
|
+
event_info['end_time'] = facebook_time.parse(end_time.strftime("%Y-%m-%d %H:%M:%S")).to_i
|
313
|
+
else
|
314
|
+
event_info['end_time'] = end_time
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
292
318
|
post_file('facebook.events.create', :event_info => event_info.to_json, nil => multipart_post_file)
|
293
319
|
end
|
294
320
|
|
data/lib/facebooker/version.rb
CHANGED
@@ -98,6 +98,14 @@ class Facebooker::UserTest < Test::Unit::TestCase
|
|
98
98
|
@user.profile_main="test"
|
99
99
|
end
|
100
100
|
|
101
|
+
|
102
|
+
def test_can_call_get_status
|
103
|
+
@session.expects(:post).with('facebook.status.get', {:uid => 1234, :limit => 4}).returns([{ "time" => 1233804858, "source" => 6628568379, "message" => "my message rocks!", "status_id" => 61436484312, 'uid' => 1234 }])
|
104
|
+
st = @user.statuses( 4 )
|
105
|
+
assert_equal st.size, 1
|
106
|
+
assert_equal st.first.message, 'my message rocks!'
|
107
|
+
end
|
108
|
+
|
101
109
|
def test_can_call_set_profile_fbml
|
102
110
|
@session.expects(:post).with('facebook.profile.setFBML', {:uid=>1234,:profile=>"profile",:profile_action=>"action",:mobile_profile=>"mobile"},false)
|
103
111
|
@user.set_profile_fbml("profile","mobile","action")
|
@@ -1079,7 +1079,7 @@ class RailsHelperTest < Test::Unit::TestCase
|
|
1079
1079
|
|
1080
1080
|
def test_init_fb_connect_with_features_and_options_js_jquery
|
1081
1081
|
assert @h.init_fb_connect("XFBML", :js => :jquery).match(/XFBML.*/)
|
1082
|
-
assert @h.init_fb_connect("XFBML", :js => :jquery).match(
|
1082
|
+
assert @h.init_fb_connect("XFBML", :js => :jquery).match(/\jQuery\(document\).ready\(/)
|
1083
1083
|
end
|
1084
1084
|
|
1085
1085
|
def test_init_fb_connect_without_options_app_settings
|
@@ -190,6 +190,29 @@ class Facebooker::SessionTest < Test::Unit::TestCase
|
|
190
190
|
assert_equal '34444349712', event_id
|
191
191
|
end
|
192
192
|
|
193
|
+
def test_can_create_events_with_time_zones
|
194
|
+
mock_http = establish_session
|
195
|
+
mock_session = flexmock(@session)
|
196
|
+
|
197
|
+
# Start time is Jan 1, 2012 at 12:30pm EST
|
198
|
+
# This should be sent to Facebook as 12:30pm PST, or 1325449800 in Epoch time
|
199
|
+
start_time = ActiveSupport::TimeZone["Eastern Time (US & Canada)"].parse("2012-01-01 12:30:00")
|
200
|
+
|
201
|
+
# End time is July 4, 2012 at 3:00pm CDT
|
202
|
+
# Should be sent to Facebook as 3:00pm PDT, or 1341439200 in Epoch time
|
203
|
+
end_time = ActiveSupport::TimeZone["Central Time (US & Canada)"].parse("2012-07-04 15:00:00")
|
204
|
+
|
205
|
+
expected_info = {
|
206
|
+
'name' => 'foo',
|
207
|
+
'category' => 'bar',
|
208
|
+
'start_time' => 1325449800,
|
209
|
+
'end_time' => 1341439200
|
210
|
+
}.to_json
|
211
|
+
|
212
|
+
mock_session.should_receive(:post_file).once.with('facebook.events.create', {:event_info => expected_info, nil => nil}).and_return(example_event_create_xml).once
|
213
|
+
mock_session.create_event('name' => 'foo', 'category' => 'bar', :start_time => start_time, :end_time => end_time)
|
214
|
+
end
|
215
|
+
|
193
216
|
def test_can_cancel_events
|
194
217
|
expect_http_posts_with_responses(example_event_cancel_xml)
|
195
218
|
assert @session.cancel_event("12345", :cancel_message => "It's raining")
|
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.55
|
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: 2009-
|
17
|
+
date: 2009-11-06 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|