Files

RFacebook::FacebookWebSession

Public Instance Methods

activate_with_previous_session(key, uid=nil, expires=nil) click to toggle source

Sets the session key directly (for example, if you have an infinite session)

key

the session key to use

# File lib/facebook_web_session.rb, line 92
def activate_with_previous_session(key, uid=nil, expires=nil)
  # set the expiration
  @session_expires = expires
  
  # set the session key
  @session_key = key

  # determine the current user's id
  if uid
    @session_user_id = uid
  else
    result = remote_call("users.getLoggedInUser")
    @session_user_id = result.at("users_getLoggedInUser_response").inner_html
  end
end
activate_with_token(auth_token) click to toggle source

Gets the session information available after current user logs in.

auth_token

string token passed back by the callback URL

# File lib/facebook_web_session.rb, line 80
def activate_with_token(auth_token)
  result = remote_call("auth.getSession", {:auth_token => auth_token})
  unless result.nil?
    @session_user_id = result.at("uid").inner_html
    @session_key = result.at("session_key").inner_html
    @session_expires = result.at("expires").inner_html
  end
end
get_install_url(options={}) click to toggle source

Gets the installation URL for this application

options.next

the page to redirect to after installation

# File lib/facebook_web_session.rb, line 66
def get_install_url(options={})
  # handle options
  nextPage = options[:next] ||= nil

  # url pieces
  optionalNext = (nextPage == nil) ? "" : "&next=#{CGI.escape(nextPage.to_s)}"

  # build and return URL
  return "http://#{WWW_HOST}#{WWW_PATH_INSTALL}?api_key=#{@api_key}#{optionalNext}"
end
get_login_url(options={}) click to toggle source

Gets the authentication URL for this application

options.next

the page to redirect to after login

options.popup

boolean, whether or not to use the popup style (defaults to false)

options.skipcookie

boolean, whether to force new Facebook login (defaults to false)

options.hidecheckbox

boolean, whether to show the "infinite session" option checkbox

# File lib/facebook_web_session.rb, line 42
def get_login_url(options={})
  # handle options
  nextPage = options[:next] ||= nil
  popup = (options[:popup] == nil) ? false : true
  skipcookie = (options[:skipcookie] == nil) ? false : true
  hidecheckbox = (options[:hidecheckbox] == nil) ? false : true
  frame = (options[:frame] == nil) ? false : true
  canvas = (options[:canvas] == nil) ? false : true

  # url pieces
  optionalNext = (nextPage == nil) ? "" : "&next=#{CGI.escape(nextPage.to_s)}"
  optionalPopup = (popup == true) ? "&popup=true" : ""
  optionalSkipCookie = (skipcookie == true) ? "&skipcookie=true" : ""
  optionalHideCheckbox = (hidecheckbox == true) ? "&hide_checkbox=true" : ""
  optionalFrame = (frame == true) ? "&fbframe=true" : ""
  optionalCanvas = (canvas == true) ? "&canvas=true" : ""

  # build and return URL
  return "http://#{WWW_HOST}#{WWW_PATH_LOGIN}?v=1.0&api_key=#{@api_key}#{optionalPopup}#{optionalNext}#{optionalSkipCookie}#{optionalHideCheckbox}#{optionalFrame}#{optionalCanvas}"
end
ready?() click to toggle source

returns true if this session is completely ready to be used and make API calls

# File lib/facebook_web_session.rb, line 109
def ready?
  return (@session_key != nil and !expired?)
end
signature(params) click to toggle source

Used for signing a set of parameters in the way that Facebook specifies: <developers.facebook.com/documentation.php?v=1.0&doc=auth>

params

a Hash containing the parameters to sign

# File lib/facebook_web_session.rb, line 117
def signature(params)
  # always sign the parameters with the API secret
  return signature_helper(params, @api_secret)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.