Class: SimpleFacebookConnect::Session
- Inherits:
-
Object
- Object
- SimpleFacebookConnect::Session
- Defined in:
- lib/simple_facebook_connect/session.rb
Constant Summary collapse
- API_SERVER_BASE_URL =
"api.facebook.com"
- API_PATH_REST =
"/restserver.php"
- WWW_SERVER_BASE_URL =
"www.facebook.com"
- WWW_PATH_LOGIN =
"/login.php"
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
-
#session_key ⇒ Object
readonly
Returns the value of attribute session_key.
Instance Method Summary collapse
-
#initialize(api_key, secret_key) ⇒ Session
constructor
A new instance of Session.
- #login_url(options = {}) ⇒ Object
- #post(method, params = {}, use_session_key = true, &proc) ⇒ Object
- #secure! ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(api_key, secret_key) ⇒ Session
Returns a new instance of Session.
13 14 15 16 17 18 19 20 21 |
# File 'lib/simple_facebook_connect/session.rb', line 13 def initialize(api_key, secret_key) @api_key = api_key @secret_key = secret_key @session_key = nil @uid = nil @auth_token = nil @secret_from_session = nil @expires = nil end |
Instance Attribute Details
#auth_token ⇒ Object
Returns the value of attribute auth_token.
9 10 11 |
# File 'lib/simple_facebook_connect/session.rb', line 9 def auth_token @auth_token end |
#session_key ⇒ Object (readonly)
Returns the value of attribute session_key.
10 11 12 |
# File 'lib/simple_facebook_connect/session.rb', line 10 def session_key @session_key end |
Instance Method Details
#login_url(options = {}) ⇒ Object
23 24 25 |
# File 'lib/simple_facebook_connect/session.rb', line 23 def login_url(={}) "http://#{WWW_SERVER_BASE_URL}#{WWW_PATH_LOGIN}?api_key=#{@api_key}&v=1.0" end |
#post(method, params = {}, use_session_key = true, &proc) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/simple_facebook_connect/session.rb', line 40 def post(method, params = {}, use_session_key = true, &proc) add_facebook_params(params, method) use_session_key && @session_key && params[:session_key] ||= @session_key final_params = params.merge(:sig => signature_for(params)) result = service.post(final_params) result = yield result if block_given? result end |
#secure! ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/simple_facebook_connect/session.rb', line 28 def secure! response = post 'facebook.auth.getSession', :auth_token => auth_token @session_key = response['session_key'] @uid = response['uid'].to_i @expires = response['expires'].to_i @secret_from_session = response['secret'] end |