Module: FbGraph::Connections::Accounts
- Included in:
- User
- Defined in:
- lib/fb_graph/connections/accounts.rb
Overview
What’s “accounts”?
Pages owned by the current user.
ref) 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) 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
Instance Method Summary collapse
Instance Method Details
#accounts(options = {}) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/fb_graph/connections/accounts.rb', line 49 def accounts( = {}) accounts = self.connection(:accounts, ) accounts.map! do |account| account[:access_token] ||= [:access_token] || self.access_token FbGraph::Page.new(account.delete(:id), account) end end |