Sha256: 63b75ded9a79df1b3b97b1f4671d93643cbf341308d53c48920748ef76bcf0f4

Contents?: true

Size: 1.96 KB

Versions: 24

Compression:

Stored size: 1.96 KB

Contents

module FbGraph
  class Application < Node
    include Connections::Albums
    include Connections::Events
    include Connections::Feed
    include Connections::Insights
    include Connections::Links
    include Connections::Notes
    include Connections::Photos
    include Connections::Picture
    include Connections::Posts
    include Connections::Statuses
    include Connections::Subscriptions
    include Connections::Tagged
    include Connections::TestUsers
    include Connections::Videos

    attr_accessor :name, :description, :category, :link, :secret

    def initialize(client_id, attributes = {})
      super
      @name         = attributes[:name]
      @description  = attributes[:description]
      @category     = attributes[:category]
      @link         = attributes[:link]
      @secret       = attributes[:secret]
    end

    # == Get OAuth access token
    # 
    # Obtain an OAuth access token associated with your application via the OAuth Client Credentials Flow.
    # 
    # ref) http://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
    def get_access_token(secret = nil)
      self.secret ||= secret
      auth = 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

  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
fb_graph-1.6.1 lib/fb_graph/application.rb
fb_graph-1.6.0 lib/fb_graph/application.rb
fb_graph-1.5.5 lib/fb_graph/application.rb
fb_graph-1.5.4 lib/fb_graph/application.rb
fb_graph-1.5.3 lib/fb_graph/application.rb
fb_graph-1.5.2 lib/fb_graph/application.rb
fb_graph-1.5.1 lib/fb_graph/application.rb
fb_graph-1.5.0 lib/fb_graph/application.rb
fb_graph-1.4.1 lib/fb_graph/application.rb
fb_graph-1.4.0 lib/fb_graph/application.rb
fb_graph-1.3.9 lib/fb_graph/application.rb
fb_graph-1.3.8 lib/fb_graph/application.rb
fb_graph-1.3.7 lib/fb_graph/application.rb
fb_graph-1.3.6 lib/fb_graph/application.rb
fb_graph-1.3.5 lib/fb_graph/application.rb
fb_graph-1.3.4 lib/fb_graph/application.rb
fb_graph-1.3.3 lib/fb_graph/application.rb
fb_graph-1.3.2 lib/fb_graph/application.rb
fb_graph-1.3.1 lib/fb_graph/application.rb
fb_graph-1.3.0 lib/fb_graph/application.rb