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.
22 23 24 25 26 27 28 29 30 |
# File 'lib/refacebook.rb', line 22 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.
15 16 17 |
# File 'lib/refacebook.rb', line 15 def api @api end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
15 16 17 |
# File 'lib/refacebook.rb', line 15 def api_key @api_key end |
#expires ⇒ Object (readonly)
Returns the value of attribute expires.
17 18 19 |
# File 'lib/refacebook.rb', line 17 def expires @expires end |
#friends ⇒ Object (readonly)
Returns the value of attribute friends.
17 18 19 |
# File 'lib/refacebook.rb', line 17 def friends @friends end |
#profile_update_time ⇒ Object (readonly)
Returns the value of attribute profile_update_time.
17 18 19 |
# File 'lib/refacebook.rb', line 17 def profile_update_time @profile_update_time end |
#secret ⇒ Object (readonly)
Returns the value of attribute secret.
15 16 17 |
# File 'lib/refacebook.rb', line 15 def secret @secret end |
#session_key ⇒ Object
Returns the value of attribute session_key.
17 18 19 |
# File 'lib/refacebook.rb', line 17 def session_key @session_key end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
17 18 19 |
# File 'lib/refacebook.rb', line 17 def time @time end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
17 18 19 |
# File 'lib/refacebook.rb', line 17 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.
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/refacebook.rb', line 49 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.
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/refacebook.rb', line 34 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 |