3 def initialize(session)
9 # Sets a cookie on Facebook
10 # +user+ The user for whom this cookie needs to be set.
11 # +name+ Name of the cookie
12 # +value+ Value of the cookie
14 # +expires+ Time when the cookie should expire. If not specified, the cookie never expires.
15 # +path+ Path relative to the application's callback URL, with which the cookie should be associated. (default value is /?
16 def set_cookie(user, name, value, expires=nil, path=nil)
17 @session.post('facebook.data.setCookie',
18 :uid => User.cast_to_facebook_id(user),
22 :path => path) {|response| response == '1'}
27 # Gets a cookie stored on Facebook
28 # +user+ The user from whom to get the cookies.
30 # +name+ The name of the cookie. If not specified, all the cookies for the given user get returned.
31 def get_cookies(user, name=nil)
32 @cookies = @session.post(
33 'facebook.data.getCookies', :uid => User.cast_to_facebook_id(user), :name => name) do |response|
34 response.map do |hash|
35 Cookie.from_hash(hash)
42 # Gets a preference stored on Facebook
43 # +pref_id+ The id of the preference to get
44 def get_preference(pref_id)
45 @session.post('facebook.data.getUserPreference', :pref_id=>pref_id)
50 # Sets a preference on Facebook
51 # +pref_id+ The id of the preference to set
52 # +value+ The value to set for this preference
53 def set_preference(pref_id, value)
54 @session.post('facebook.data.setUserPreference', :pref_id=>pref_id, :value=>value)