forked from rocket-rentals/facebooker-rails3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass on extracting facebook ENV and Global vars into an
Adapter class. BeboAdapter seesm to be working. Need to create some tests.
- Loading branch information
David Clements
committed
Jul 7, 2008
1 parent
3b5c687
commit da5b78a
Showing
9 changed files
with
230 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
# Things that don't actually work in BEBO | ||
|
||
Facebooker::PublishTemplatizedAction | ||
module Facebooker | ||
class User | ||
def set_profile_fbml_with_bebo_adapter(profile_fbml, mobile_fbml, profile_action_fbml) | ||
if(Facebooker::BeboSession === self.session ) | ||
self.session.post('facebook.profile.setFBML', :uid => @id, :markup => profile_fbml) | ||
else | ||
set_profile_fbml_without_bebo_adapter(profile_fbml,mobile_fbml, profile_action_fbml) | ||
end | ||
end | ||
alias_method_chain :set_profile_fbml, :bebo_adapter | ||
|
||
private | ||
|
||
BEBO_FIELDS = FIELDS - [:meeting_sex, :wall_count, :meeting_for] | ||
def collect(fields) | ||
if(Facebooker::BeboSession === self.session ) | ||
BEBO_FIELDS.reject{|field_name| !fields.empty? && !fields.include?(field_name)}.join(',') | ||
else | ||
FIELDS.reject{|field_name| !fields.empty? && !fields.include?(field_name)}.join(',') | ||
end | ||
end | ||
end | ||
|
||
|
||
class PublishTemplatizedAction < Parser#:nodoc: | ||
class <<self | ||
def process_with_bebo_adapter(data) | ||
if(Facebooker.is_for?(:bebo)) | ||
element('feed_publishTemplatizedAction_response', data).text_value | ||
else | ||
process_without_bebo_adapter(data) | ||
end | ||
end | ||
alias_method_chain :process, :bebo_adapter | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
module Facebooker | ||
class AdapterBase | ||
class << self | ||
def facebook_path_prefix | ||
"/" + (@facebook_path_prefix || canvas_page_name) | ||
end | ||
|
||
def facebook_path_prefix=(prefix) | ||
@facebook_path_prefix = prefix | ||
end | ||
|
||
def facebooker_config | ||
return @facebooker_config if @facebooker_config | ||
|
||
facebook_config_file = "#{RAILS_ROOT}/config/facebooker.yml" | ||
if File.exist?(facebook_config_file) | ||
@facebooker_config = YAML.load_file(facebook_config_file)[RAILS_ENV] | ||
end | ||
end | ||
|
||
def api_server_base_url | ||
"http://" + api_server_base | ||
end | ||
|
||
def is_for?(application_context) | ||
raise "SubClassShouldDefine" | ||
end | ||
|
||
|
||
end | ||
|
||
end | ||
class FacebookAdapter < AdapterBase | ||
class << self | ||
def canvas_page_name | ||
facebooker_config["canvas_page_name"] | ||
end | ||
def api_key | ||
facebooker_config["api_key"] | ||
end | ||
|
||
def secret_key | ||
facebooker_config["secret_key"] | ||
end | ||
|
||
def canvas_server_base | ||
"apps.facebook.com" | ||
end | ||
|
||
def api_server_base | ||
ENV["FACEBOOKER_API"] == "new" ? "api.new.facebook.com" : "api.facebook.com" | ||
end | ||
|
||
def api_rest_path | ||
"/restserver.php" | ||
end | ||
|
||
def is_for?(application_context) | ||
application_context == :facebook | ||
end | ||
|
||
def www_server_base_url | ||
ENV["FACEBOOKER_API"] == "new" ? "www.new.facebook.com" : "www.facebook.com" | ||
end | ||
|
||
def login_url_base(api_key) | ||
"http://#{Facebooker.www_server_base_url}/login.php?api_key=#{api_key}&v=1.0" | ||
end | ||
|
||
def install_url_base(api_key) | ||
"http://#{Facebooker.www_server_base_url}/install.php?api_key=#{api_key}&v=1.0" | ||
end | ||
|
||
end | ||
end | ||
end | ||
|
||
|
||
module Facebooker | ||
class BeboAdapter < AdapterBase | ||
class << self | ||
def canvas_page_name | ||
facebooker_config["bebo_canvas_page_name"] | ||
end | ||
def canvas_server_base | ||
"apps.bebo.com" | ||
end | ||
|
||
def api_key | ||
facebooker_config["bebo_api_key"] | ||
end | ||
|
||
def secret_key | ||
facebooker_config["bebo_secret_key"] | ||
end | ||
|
||
def api_server_base | ||
'apps.bebo.com' | ||
end | ||
|
||
def api_rest_path | ||
"/restserver.php" | ||
end | ||
|
||
def is_for?(application_context) | ||
application_context == :bebo | ||
end | ||
|
||
def www_server_base_url | ||
"www.bebo.com" | ||
end | ||
|
||
|
||
def login_url_base(api_key) | ||
options = default_login_url_options.merge(options) | ||
"http://#{Facebooker.www_server_base_url}/SignIn.jsp?ApiKey=#{api_key}&v=1.0" | ||
end | ||
|
||
def install_url_base(api_key) | ||
"http://#{Facebooker.www_server_base_url}/c/apps/add?ApiKey=#{api_key}&v=1.0" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters