Class: Facebook::Client
- Inherits:
-
Object
- Object
- Facebook::Client
- Defined in:
- lib/facebook/client.rb
Overview
Class Attribute Summary collapse
-
.app_id ⇒ Object
Returns the value of attribute app_id.
-
.secret ⇒ Object
Returns the value of attribute secret.
Class Method Summary collapse
Instance Method Summary collapse
-
#authorize_url(params = {}) ⇒ Object
params: redirect_uri, scope, display.
- #get_access_token(code, redirect_uri) ⇒ Object
- #get_user_info(access_token, path) ⇒ Object
-
#initialize(app_id, secret, options = {}) ⇒ Client
constructor
A new instance of Client.
- #login_handler(options = {}) ⇒ Object
- #restore_access_token(token_string) ⇒ Object
Constructor Details
#initialize(app_id, secret, options = {}) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 |
# File 'lib/facebook/client.rb', line 15 def initialize(app_id, secret, = {}) @oauth = self.class.oauth_client(app_id, secret) @default_params = { :scope => [:permissions], :display => [:display] } @user_fields = Array([:user_fields]) end |
Class Attribute Details
.app_id ⇒ Object
Returns the value of attribute app_id.
7 8 9 |
# File 'lib/facebook/client.rb', line 7 def app_id @app_id end |
.secret ⇒ Object
Returns the value of attribute secret.
7 8 9 |
# File 'lib/facebook/client.rb', line 7 def secret @secret end |
Class Method Details
.oauth_client(app_id = nil, secret = nil) ⇒ Object
10 11 12 13 |
# File 'lib/facebook/client.rb', line 10 def self.oauth_client(app_id = nil, secret = nil) self.app_id, self.secret = app_id, secret unless app_id.nil? OAuth2::Client.new(self.app_id, self.secret, :site => 'https://graph.facebook.com') end |
Instance Method Details
#authorize_url(params = {}) ⇒ Object
params: redirect_uri, scope, display
22 23 24 |
# File 'lib/facebook/client.rb', line 22 def (params = {}) @oauth.web_server.(@default_params.merge(params)) end |
#get_access_token(code, redirect_uri) ⇒ Object
26 27 28 |
# File 'lib/facebook/client.rb', line 26 def get_access_token(code, redirect_uri) @oauth.web_server.get_access_token(code, :redirect_uri => redirect_uri) end |
#get_user_info(access_token, path) ⇒ Object
38 39 40 |
# File 'lib/facebook/client.rb', line 38 def get_user_info(access_token, path) access_token.get(path, :fields => @user_fields.join(',')) end |
#login_handler(options = {}) ⇒ Object
34 35 36 |
# File 'lib/facebook/client.rb', line 34 def login_handler( = {}) Login.new(self, ) end |
#restore_access_token(token_string) ⇒ Object
30 31 32 |
# File 'lib/facebook/client.rb', line 30 def restore_access_token(token_string) OAuth2::AccessToken.new(@oauth, token_string) end |