Class: Facebook::Client
- Inherits:
-
Object
- Object
- Facebook::Client
- Defined in:
- lib/facebook/client.rb
Overview
Class Attribute Summary collapse
-
.last_oauth_client ⇒ Object
readonly
Returns the value of attribute last_oauth_client.
Instance Attribute Summary collapse
-
#oauth ⇒ Object
readonly
Returns the value of attribute oauth.
Class Method Summary collapse
- .access_token_options ⇒ Object
- .oauth_client(app_id, secret, &block) ⇒ Object
- .restore_access_token(token_string) ⇒ Object
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 = {}, &block) ⇒ Client
constructor
A new instance of Client.
- #login_handler(options = {}) ⇒ Object
Constructor Details
#initialize(app_id, secret, options = {}, &block) ⇒ Client
Returns a new instance of Client.
27 28 29 30 31 |
# File 'lib/facebook/client.rb', line 27 def initialize(app_id, secret, = {}, &block) @oauth = self.class.oauth_client(app_id, secret, &block) @default_params = { :scope => [:permissions], :display => [:display] } @user_fields = Array([:user_fields]) end |
Class Attribute Details
.last_oauth_client ⇒ Object (readonly)
Returns the value of attribute last_oauth_client.
7 8 9 |
# File 'lib/facebook/client.rb', line 7 def last_oauth_client @last_oauth_client end |
Instance Attribute Details
#oauth ⇒ Object (readonly)
Returns the value of attribute oauth.
25 26 27 |
# File 'lib/facebook/client.rb', line 25 def oauth @oauth end |
Class Method Details
.access_token_options ⇒ Object
17 18 19 |
# File 'lib/facebook/client.rb', line 17 def self. {:mode => :query, :param_name => 'access_token'} end |
.oauth_client(app_id, secret, &block) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/facebook/client.rb', line 10 def self.oauth_client(app_id, secret, &block) @last_oauth_client = OAuth2::Client.new app_id, secret, :site => 'https://graph.facebook.com', :token_url => '/oauth/access_token', &block end |
.restore_access_token(token_string) ⇒ Object
21 22 23 |
# File 'lib/facebook/client.rb', line 21 def self.restore_access_token(token_string) OAuth2::AccessToken.new(last_oauth_client, token_string, ) end |
Instance Method Details
#authorize_url(params = {}) ⇒ Object
params: redirect_uri, scope, display
34 35 36 |
# File 'lib/facebook/client.rb', line 34 def (params = {}) @oauth.auth_code.(@default_params.merge(params)) end |
#get_access_token(code, redirect_uri) ⇒ Object
38 39 40 41 42 |
# File 'lib/facebook/client.rb', line 38 def get_access_token(code, redirect_uri) token = @oauth.auth_code.get_token(code, :redirect_uri => redirect_uri, :parse => :query) token..update(self.class.) token end |
#get_user_info(access_token, path) ⇒ Object
48 49 50 |
# File 'lib/facebook/client.rb', line 48 def get_user_info(access_token, path) access_token.get(path, :fields => @user_fields.join(',')) end |