Sha256: 579c9acd16d9a5926922d48e939c434cfee2d8958744371960467030135f7c93

Contents?: true

Size: 1.81 KB

Versions: 81

Compression:

Stored size: 1.81 KB

Contents

module Facebooker
  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.
    # +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,
        :path => path) {|response| response == '1'}
    end

    ##
    # ** BETA ***
    # Gets a cookie stored on Facebook
    # +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(
        '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

    ##
    # ** BETA ***
    # Gets a preference stored on Facebook
    # +pref_id+	The id of the preference to get
    def get_preference(pref_id)
      @session.post('facebook.data.getUserPreference', :pref_id=>pref_id)
    end

    ##
    # ** BETA ***
    # Sets a preference on Facebook
    # +pref_id+	The id of the preference to set
    # +value+ The value to set for this preference
    def set_preference(pref_id, value)
      @session.post('facebook.data.setUserPreference', :pref_id=>pref_id, :value=>value)
    end
  end
end

Version data entries

81 entries across 81 versions & 21 rubygems

Version Path
fs-facebooker-1.0.37 lib/facebooker/data.rb
micahwedemeyer-facebooker-1.0.50 lib/facebooker/data.rb
micahwedemeyer-facebooker-1.0.51 lib/facebooker/data.rb
mmangino-facebooker-1.0.32 lib/facebooker/data.rb
mmangino-facebooker-1.0.36 lib/facebooker/data.rb
mmangino-facebooker-1.0.37 lib/facebooker/data.rb
mmangino-facebooker-1.0.38 lib/facebooker/data.rb
mmangino-facebooker-1.0.39 lib/facebooker/data.rb
mmangino-facebooker-1.0.40 lib/facebooker/data.rb
mmangino-facebooker-1.0.41 lib/facebooker/data.rb
mmangino-facebooker-1.0.42 lib/facebooker/data.rb
mmangino-facebooker-1.0.43 lib/facebooker/data.rb
mmangino-facebooker-1.0.44 lib/facebooker/data.rb
mmangino-facebooker-1.0.45 lib/facebooker/data.rb
mmangino-facebooker-1.0.46 lib/facebooker/data.rb
mmangino-facebooker-1.0.47 lib/facebooker/data.rb
mmangino-facebooker-1.0.48 lib/facebooker/data.rb
mmangino-facebooker-1.0.49 lib/facebooker/data.rb
mmangino-facebooker-1.0.50 lib/facebooker/data.rb
mwilliams-facebooker-1.0.40 lib/facebooker/data.rb