Things that don’t actually work as expected in BEBO
Set the current adapter
# File lib/facebooker.rb, line 103 def all_api_keys [ @raw_facebooker_configuration['api_key'] ] + ( @raw_facebooker_configuration['alternative_keys'] ? @raw_facebooker_configuration['alternative_keys'].keys : [] ) end
Sets the Facebook environment based on a hash of options. By default the hash passed in is loaded from facebooker.yml, but it can also be passed in manually every request to run multiple Facebook apps off one Rails app.
# File lib/facebooker.rb, line 56 def apply_configuration(config) ENV['FACEBOOK_API_KEY'] = config['api_key'] ENV['FACEBOOK_SECRET_KEY'] = config['secret_key'] ENV['FACEBOOKER_RELATIVE_URL_ROOT'] = config['canvas_page_name'] ENV['FACEBOOKER_API'] = config['api'] if config.has_key?('set_asset_host_to_callback_url') Facebooker.set_asset_host_to_callback_url = config['set_asset_host_to_callback_url'] end if Object.const_defined?("ActionController") and Facebooker.set_asset_host_to_callback_url ActionController::Base.asset_host = config['callback_url'] end Facebooker.timeout = config['timeout'] @facebooker_configuration = config # must be set before adapter loaded load_adapter(:fb_sig_api_key => config['api_key']) facebooker_config end
Get the current adapter
# File lib/facebooker.rb, line 139 def current_adapter @current_adapter || Facebooker::AdapterBase.default_adapter end
Default is canvas_page_name in yml file
# File lib/facebooker.rb, line 152 def facebook_path_prefix current_adapter.facebook_path_prefix end
# File lib/facebooker.rb, line 147 def facebook_path_prefix=(path) current_adapter.facebook_path_prefix = path end
# File lib/facebooker.rb, line 74 def facebooker_config @facebooker_configuration end
# File lib/facebooker.rb, line 121 def fetch_config_for(api_key) if @raw_facebooker_configuration['api_key'] == api_key return @raw_facebooker_configuration elsif @raw_facebooker_configuration['alternative_keys'] and @raw_facebooker_configuration['alternative_keys'].keys.include?(api_key) return @raw_facebooker_configuration['alternative_keys'][api_key].merge( 'api_key' => api_key ) end return false end
# File lib/facebooker.rb, line 156 def is_for?(application_container) current_adapter.is_for?(application_container) end
# File lib/facebooker.rb, line 9 def self.json_decode(str) JSON.parse(str) end
# File lib/facebooker.rb, line 13 def self.json_encode(o) JSON.dump(o) end
# File lib/facebooker.rb, line 143 def load_adapter(params) self.current_adapter = Facebooker::AdapterBase.load_adapter(params) end
# File lib/facebooker.rb, line 43 def load_configuration(facebooker_yaml_file) return false unless File.exist?(facebooker_yaml_file) @raw_facebooker_configuration = YAML.load(ERB.new(File.read(facebooker_yaml_file)).result) if defined? RAILS_ENV @raw_facebooker_configuration = @raw_facebooker_configuration[RAILS_ENV] end Thread.current[:fb_api_config] = @raw_facebooker_configuration unless Thread.current[:fb_api_config] apply_configuration(@raw_facebooker_configuration) end
# File lib/facebooker/logging.rb, line 7 def self.logger @@logger end
# File lib/facebooker/logging.rb, line 4 def self.logger=(logger) @@logger = logger end
If this request is_canvas_request then use the application name as the url root
# File lib/facebooker.rb, line 196 def request_for_canvas(is_canvas_request) original_path_prefix = @path_prefix begin @path_prefix = facebook_path_prefix if is_canvas_request yield ensure @path_prefix = original_path_prefix end end
# File lib/facebooker.rb, line 168 def timeout @timeout end
# File lib/facebooker.rb, line 164 def timeout=(val) @timeout = val.to_i end
# File lib/facebooker.rb, line 113 def with_all_applications(&block) all_api_keys.each do |current_api_key| with_application(current_api_key) do block.call end end end
# File lib/facebooker.rb, line 78 def with_application(api_key, &block) config = fetch_config_for( api_key ) unless config self.logger.info "Can't find facebooker config: '#{api_key}'" if self.logger yield if block_given? return end # Save the old config to handle nested activation. If no app context is # set yet, use default app's configuration. old = Thread.current[:fb_api_config] ? Thread.current[:fb_api_config].dup : @raw_facebooker_configuration if block_given? begin self.logger.info "Swapping facebooker config: '#{api_key}'" if self.logger Thread.current[:fb_api_config] = apply_configuration(config) yield ensure Thread.current[:fb_api_config] = old if old && !old.empty? apply_configuration(Thread.current[:fb_api_config]) end end end
Set the asset path to the canvas path for just this one request by definition, we will make this a canvas request
# File lib/facebooker.rb, line 182 def with_asset_path_for_canvas original_asset_host = ActionController::Base.asset_host begin ActionController::Base.asset_host = Facebooker.api_server_base_url request_for_canvas(true) do yield end ensure ActionController::Base.asset_host = original_asset_host end end