lib/facebooker/session.rb in taweili-facebooker-1.0.41 vs lib/facebooker/session.rb in taweili-facebooker-1.0.45
- old
+ new
@@ -48,10 +48,11 @@
class FQLFieldDoesNotExist < StandardError; end
class FQLTableDoesNotExist < StandardError; end
class FQLStatementNotIndexable < StandardError; end
class FQLFunctionDoesNotExist < StandardError; end
class FQLWrongNumberArgumentsPassedToFunction < StandardError; end
+ class PermissionError < StandardError; end
class InvalidAlbumId < StandardError; end
class AlbumIsFull < StandardError; end
class MissingOrInvalidImageFile < StandardError; end
class TooManyUnapprovedPhotosPending < StandardError; end
class ExtendedPermissionRequired < StandardError; end
@@ -392,18 +393,26 @@
##
# Register a template bundle with Facebook.
# returns the template id to use to send using this template
def register_template_bundle(one_line_story_templates,short_story_templates=nil,full_story_template=nil, action_links=nil)
- parameters = {:one_line_story_templates => Array(one_line_story_templates).to_json}
-
- parameters[:action_links] = action_links.to_json unless action_links.blank?
-
- parameters[:short_story_templates] = Array(short_story_templates).to_json unless short_story_templates.blank?
-
- parameters[:full_story_template] = full_story_template.to_json unless full_story_template.blank?
-
+ templates = ensure_array(one_line_story_templates)
+ parameters = {:one_line_story_templates => templates.to_json}
+
+ unless action_links.blank?
+ parameters[:action_links] = action_links.to_json
+ end
+
+ unless short_story_templates.blank?
+ templates = ensure_array(short_story_templates)
+ parameters[:short_story_templates] = templates.to_json
+ end
+
+ unless full_story_template.blank?
+ parameters[:full_story_template] = full_story_template.to_json
+ end
+
post("facebook.feed.registerTemplateBundle", parameters, false)
end
##
# publish a previously rendered template bundle
@@ -551,11 +560,11 @@
result
end
end
def post(method, params = {}, use_session_key = true, &proc)
- if batch_request?
+ if batch_request? or Facebooker::Logging.skip_api_logging
post_without_logging(method, params, use_session_key, &proc)
else
Logging.log_fb_api(method, params) do
post_without_logging(method, params, use_session_key, &proc)
end
@@ -625,9 +634,13 @@
Array === x ? Facebooker.json_encode(x) : x
}.join("=")
collection
end.sort.join
Digest::MD5.hexdigest([raw_string, secret_for_method(params[:method])].join)
+ end
+
+ def ensure_array(value)
+ value.is_a?(Array) ? value : [value]
end
end
class CanvasSession < Session
def default_login_url_options