Class: RFacebook::FacebookWebSession
- Inherits:
-
FacebookSession
- Object
- FacebookSession
- RFacebook::FacebookWebSession
- Defined in:
- lib/facebook_web_session.rb
Instance Attribute Summary
Attributes inherited from FacebookSession
#logger, #session_expires, #session_key, #session_user_id
Instance Method Summary collapse
-
#activate_with_previous_session(key, uid = nil, expires = nil) ⇒ Object
Sets the session key directly (for example, if you have an infinite session).
-
#activate_with_token(auth_token) ⇒ Object
Gets the session information available after current user logs in.
-
#get_install_url(options = {}) ⇒ Object
Gets the installation URL for this application.
-
#get_login_url(options = {}) ⇒ Object
Gets the authentication URL for this application.
-
#ready? ⇒ Boolean
returns true if this session is completely ready to be used and make API calls.
-
#signature(params) ⇒ Object
Used for signing a set of parameters in the way that Facebook specifies: <developers.facebook.com/documentation.php?v=1.0&doc=auth>.
Methods inherited from FacebookSession
#_dump, _load, #expired?, #initialize, #is_activated?, #is_expired?, #is_ready?, #is_valid?, #last_error_code, #last_error_message, #quiet=, #quiet?, #suppress_errors, #suppress_errors=
Constructor Details
This class inherits a constructor from RFacebook::FacebookSession
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RFacebook::FacebookSession
Instance Method Details
#activate_with_previous_session(key, uid = nil, expires = nil) ⇒ Object
Sets the session key directly (for example, if you have an infinite session)
- key
-
the session key to use
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# 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) ⇒ Object
Gets the session information available after current user logs in.
- auth_token
-
string token passed back by the callback URL
80 81 82 83 84 85 86 87 |
# 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 = {}) ⇒ Object
Gets the installation URL for this application
- options.next
-
the page to redirect to after installation
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/facebook_web_session.rb', line 66 def get_install_url(={}) # handle options nextPage = [: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 = {}) ⇒ Object
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
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/facebook_web_session.rb', line 42 def get_login_url(={}) # handle options nextPage = [:next] ||= nil popup = ([:popup] == nil) ? false : true = ([:skipcookie] == nil) ? false : true hidecheckbox = ([:hidecheckbox] == nil) ? false : true frame = ([:frame] == nil) ? false : true canvas = ([:canvas] == nil) ? false : true # url pieces optionalNext = (nextPage == nil) ? "" : "&next=#{CGI.escape(nextPage.to_s)}" optionalPopup = (popup == true) ? "&popup=true" : "" optionalSkipCookie = ( == 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? ⇒ Boolean
returns true if this session is completely ready to be used and make API calls
109 110 111 |
# File 'lib/facebook_web_session.rb', line 109 def ready? return (@session_key != nil and !expired?) end |
#signature(params) ⇒ Object
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
117 118 119 120 |
# 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 |