Class: FbGraph::Application
- Includes:
- Connections::Albums, Connections::Events, Connections::Feed, Connections::Insights, Connections::Links, Connections::Notes, Connections::Photos, Connections::Picture, Connections::Posts, Connections::Statuses, Connections::Subscriptions, Connections::Tagged, Connections::Videos
- Defined in:
- lib/fb_graph/application.rb
Instance Attribute Summary collapse
-
#category ⇒ Object
Returns the value of attribute category.
-
#description ⇒ Object
Returns the value of attribute description.
-
#link ⇒ Object
Returns the value of attribute link.
-
#name ⇒ Object
Returns the value of attribute name.
-
#secret ⇒ Object
Returns the value of attribute secret.
Attributes inherited from Node
#access_token, #endpoint, #identifier
Instance Method Summary collapse
-
#get_access_token(secret = nil) ⇒ Object
Get OAuth access token.
-
#initialize(client_id, attributes = {}) ⇒ Application
constructor
A new instance of Application.
Methods included from Connections::Insights
Methods included from Connections::Subscriptions
#subscribe!, #subscriptions, #unsubscribe!
Methods included from Connections::Events
Methods included from Connections::Notes
Methods included from Connections::Videos
Methods included from Connections::Statuses
Methods included from Connections::Albums
Methods included from Connections::Photos
Methods included from Connections::Links
Methods included from Connections::Tagged
Methods included from Connections::Picture
Methods included from Connections::Posts
Methods included from Connections::Feed
Methods inherited from Node
#connection, #destroy, fetch, #fetch
Methods included from Comparison
Constructor Details
#initialize(client_id, attributes = {}) ⇒ Application
Returns a new instance of Application.
19 20 21 22 23 24 25 26 |
# File 'lib/fb_graph/application.rb', line 19 def initialize(client_id, attributes = {}) super @name = attributes[:name] @description = attributes[:description] @category = attributes[:category] @link = attributes[:link] @secret = attributes[:secret] end |
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
17 18 19 |
# File 'lib/fb_graph/application.rb', line 17 def category @category end |
#description ⇒ Object
Returns the value of attribute description.
17 18 19 |
# File 'lib/fb_graph/application.rb', line 17 def description @description end |
#link ⇒ Object
Returns the value of attribute link.
17 18 19 |
# File 'lib/fb_graph/application.rb', line 17 def link @link end |
#name ⇒ Object
Returns the value of attribute name.
17 18 19 |
# File 'lib/fb_graph/application.rb', line 17 def name @name end |
#secret ⇒ Object
Returns the value of attribute secret.
17 18 19 |
# File 'lib/fb_graph/application.rb', line 17 def secret @secret end |
Instance Method Details
#get_access_token(secret = nil) ⇒ Object
Get OAuth access token
Obtain an OAuth access token associated with your application via the OAuth Client Credentials Flow.
ref) developers.facebook.com/docs/api#analytics
app = FbGraph::Application.new(APP_ID)
app.get_access_token
# => access token as String
app.access_token # once get_access_token is called, access token is cached.
# => access token as String
This method is automatically called when access token needed and application secret has already given.
app = FbGraph::Application.new(APP_ID, :secret => APP_SECRET)
app.subscriptions # get_access_token is called automatically
# => Array of FbGraph::Subscription
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fb_graph/application.rb', line 45 def get_access_token(secret = nil) self.secret ||= secret auth = FbGraph::Auth.new(self.identifier, self.secret) response_string = auth.client.request(:post, auth.client.access_token_url, { :client_id => self.identifier, :client_secret => self.secret, :type => 'client_cred' }) self.access_token = response_string.split('=').last end |