Skip to content

Commit

Permalink
nokogiri can optionally be used as the XML parser
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed May 4, 2009
1 parent 00b3e47 commit ed216bb
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 168 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rdoc
Expand Up @@ -3,6 +3,7 @@
* New Features

* Facebooker::User#publish_to for publishing to a Wall or News Stream
* Optionally parses with Nokogiri. Just require 'nokogiri' in your app.

=== 1.0.13 / 2009-02-26

Expand Down
18 changes: 9 additions & 9 deletions lib/facebooker/adapters/bebo_adapter.rb
@@ -1,14 +1,14 @@
module Facebooker
class BeboAdapter < AdapterBase

def canvas_server_base
"apps.bebo.com"
end

def api_server_base
'apps.bebo.com'
end

def api_rest_path
"/restserver.php"
end
Expand Down Expand Up @@ -44,9 +44,9 @@ def set_profile_fbml_with_bebo_adapter(profile_fbml, mobile_fbml, profile_action
end
alias_method :set_profile_fbml_without_bebo_adapter, :set_profile_fbml
alias_method :set_profile_fbml, :set_profile_fbml_with_bebo_adapter

private

BEBO_FIELDS = FIELDS - [:meeting_sex, :wall_count, :meeting_for]

remove_method :collect
Expand All @@ -57,15 +57,15 @@ def collect(fields)
else
FIELDS.reject{|field_name| !fields.empty? && !fields.include?(field_name)}.join(',')
end
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
element('feed_publishTemplatizedAction_response', data).content
else
process_without_bebo_adapter(data)
end
Expand Down
28 changes: 14 additions & 14 deletions lib/facebooker/data.rb
Expand Up @@ -3,40 +3,40 @@ class Data
def initialize(session)
@session = session
end

##
# ** BETA ***
# Sets a cookie on Facebook
# +user+ The user for whom this cookie needs to be set.
# +name+ Name of the cookie
# +value+ Value of the cookie
# Optional:
# +expires+ Time when the cookie should expire. If not specified, the cookie never expires.
# +expires+ Time when the cookie should expire. If not specified, the cookie never expires.
# +path+ Path relative to the application's callback URL, with which the cookie should be associated. (default value is /?
def set_cookie(user, name, value, expires=nil, path=nil)
@session.post('facebook.data.setCookie',
:uid => User.cast_to_facebook_id(user),
:name => name,
:value => value,
:expires => expires,
@session.post('facebook.data.setCookie',
:uid => User.cast_to_facebook_id(user),
:name => name,
:value => value,
:expires => expires,
:path => path) {|response| response == '1'}
end

##
# ** BETA ***
# Gets a cookie stored on Facebook
# +user+ The user from whom to get the cookies.
# Optional:
# +user+ The user from whom to get the cookies.
# Optional:
# +name+ The name of the cookie. If not specified, all the cookies for the given user get returned.
def get_cookies(user, name=nil)
@cookies = @session.post(
@cookies = @session.post(
'facebook.data.getCookies', :uid => User.cast_to_facebook_id(user), :name => name) do |response|
response.map do |hash|
Cookie.from_hash(hash)
end
end
end
end

##
# ** BETA ***
# Gets a preference stored on Facebook
Expand All @@ -54,4 +54,4 @@ def set_preference(pref_id, value)
@session.post('facebook.data.setUserPreference', :pref_id=>pref_id, :value=>value)
end
end
end
end

0 comments on commit ed216bb

Please sign in to comment.