Class: ReFacebook::Session
- Inherits:
-
Object
- Object
- ReFacebook::Session
- Defined in:
- lib/refacebook.rb
Overview
ReFacebook::Session is the main store for a facebook session.
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#expires ⇒ Object
readonly
Returns the value of attribute expires.
-
#friends ⇒ Object
readonly
Returns the value of attribute friends.
-
#profile_update_time ⇒ Object
readonly
Returns the value of attribute profile_update_time.
-
#secret ⇒ Object
readonly
Returns the value of attribute secret.
-
#session_key ⇒ Object
readonly
Returns the value of attribute session_key.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
-
#get_login_url(*args) ⇒ Object
Generate a redirect path to the default login page.
-
#initialize(api_key, secret) ⇒ Session
constructor
Create a new session.
-
#update_session_params(params) ⇒ Object
Update the session variables based on the values that are sent in from the facebook parameters.
Constructor Details
#initialize(api_key, secret) ⇒ Session
Create a new session. api_key and secret are the Facebook API and Secret keys.
19 20 21 22 23 24 25 26 27 |
# File 'lib/refacebook.rb', line 19 def initialize api_key, secret @api_key = api_key @secret = secret @api = API.new(api_key, secret) %w{user friends session_key expires time profile_update_time}.each do |var| instance_variable_set "@#{var}", nil end end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
12 13 14 |
# File 'lib/refacebook.rb', line 12 def api @api end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
12 13 14 |
# File 'lib/refacebook.rb', line 12 def api_key @api_key end |
#expires ⇒ Object (readonly)
Returns the value of attribute expires.
14 15 16 |
# File 'lib/refacebook.rb', line 14 def expires @expires end |
#friends ⇒ Object (readonly)
Returns the value of attribute friends.
14 15 16 |
# File 'lib/refacebook.rb', line 14 def friends @friends end |
#profile_update_time ⇒ Object (readonly)
Returns the value of attribute profile_update_time.
14 15 16 |
# File 'lib/refacebook.rb', line 14 def profile_update_time @profile_update_time end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
12 13 14 |
# File 'lib/refacebook.rb', line 12 def secret @secret end |
#session_key ⇒ Object
Returns the value of attribute session_key.
14 15 16 |
# File 'lib/refacebook.rb', line 14 def session_key @session_key end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
14 15 16 |
# File 'lib/refacebook.rb', line 14 def time @time end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
14 15 16 |
# File 'lib/refacebook.rb', line 14 def user @user end |
Instance Method Details
#get_login_url(*args) ⇒ Object
Generate a redirect path to the default login page.
- :next
-
The page to redirect to after login.
- :canvas
-
Optional. If this is true redirects to the canvas page.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/refacebook.rb', line 46 def get_login_url *args params = {} params['v'] = '1.0' params['api_key'] = @api_key params['next'] = args[0][:next] if args[0][:canvas] params['canvas'] = '1' end LoginUrl + '?' + params.collect {|k,v| "#{k}=#{v}"}.join('&') end |
#update_session_params(params) ⇒ Object
Update the session variables based on the values that are sent in from the facebook parameters.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/refacebook.rb', line 31 def update_session_params params @user = params['fb_sig_user'] @friends = params['fb_sig_friends'].split(',') @session_key = params['fb_sig_session_key'] @expires = params['fb_sig_expires'] @time = params['fb_sig_time'] @profile_update_time = params['fb_sig_profile_update_time'] end |