Sha256: 8add5f191243de382b7a18dfca12a5e4e54b4e17344cb66276cb47bd45731bdd

Contents?: true

Size: 1.73 KB

Versions: 24

Compression:

Stored size: 1.73 KB

Contents

module FbGraph
  module Connections
    # = What's "accounts"?
    #
    # Pages owned by the current user.
    #
    # ref) http://developers.facebook.com/docs/api#impersonation
    #
    # = Authentication
    #
    # * Access token is required.
    # * "manage_pages" permission is optional.
    #
    # If the "manage_pages" permission has been granted,
    # this connection also yields access_tokens that can be used to query the Graph API on behalf of the page.
    #
    # ref) http://developers.facebook.com/docs/reference/api/user
    #
    # = Connected with
    #
    # * FbGraph::User
    #
    # == Fetch
    #
    #   pages = FbGraph::User.me(ACCESS_TOKEN).accounts
    #   # => array of FbGraph::Page
    #   pages.first.access_token
    #   # => String if "manage_pages" permission has been granted, nil if not.
    #
    # = Notes
    #
    # == Access token of the page
    #
    # Using given access token, you can do those things as the page, not as yourself.
    #
    # * update the page's wall
    # * create new page's album and upload photos into it
    # * create and manage an event
    # * etc.
    #
    # See RDoc for FbGraph::Page for more details.
    #
    #   page = FbGraph::User.me(ACCESS_TOKEN).accounts.first
    #   page.access_token
    #   # => given because "manage_pages" permission has been granted.
    #   page.feed!(:message => 'Updating via FbGraph')
    #   # => update the page's wall, not the user's wall
    module Accounts
      def accounts(options = {})
        accounts = self.connection(:accounts, options)
        accounts.map! do |account|
          account[:access_token] ||= options[:access_token] || self.access_token
          Page.new(account.delete(:id), account)
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

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