-
-
Notifications
You must be signed in to change notification settings - Fork 191
Page Management
nov edited this page Nov 7, 2012
·
5 revisions
You need the page’s access token to manage your page.
Your (an user’s) access token doesn’t work here.
See this official document for more details.
https://developers.facebook.com/docs/reference/api/page/
# Get an access token of page.
page = FbGraph::Page.new('FbGraph').fetch(
:access_token => USER_ACCESS_TOKEN,
:fields => :access_token
)
# List of all *enabled* settings
page.settings
# Ask each setting is enabled or disabled
page.users_can_post? # => boolean
page.users_can_post_photos? # => boolean
page.users_can_tag_photos? # => boolean
page.users_can_post_videos? # => boolean
# Enable each setting
page.users_can_post! # => boolean
page.users_can_post_photos! # => boolean
page.users_can_tag_photos! # => boolean
page.users_can_post_videos! # => boolean
# Disable each setting
page.users_cannot_post! # => boolean
page.users_cannot_post_photos! # => boolean
page.users_cannot_tag_photos! # => boolean
page.users_cannot_post_videos! # => boolean
# You can enable/disable settings like this too.
page.enable!(:users_can_tag_photos)
page.disable!(:users_can_tag_photos)
# Get an access token of page
page = FbGraph::Page.new('FbGraph').fetch(
:access_token => USER_ACCESS_TOKEN,
:fields => :access_token
)
# List of all installed tabs (includes wall & info tabs)
tabs = page.tabs
# Install a tab
tab = page.tab!(:app_id => APP_ID_YOU_WANT_TO_INSTALL)
# Update an existing tab
tab.update(
:custom_name => 'Custom Name',
:position => 1
)
# Uninstall a tab
tab.destroy
page = FbGraph::Page.new('FbGraph').fetch(
:access_token => ACCESS_TOKEN,
:fields => :access_token
)
posts = page.promotable_posts
posts.publishable? # => boolean
posts.schedulable? # => boolean
posts.scheduled? # => boolean
# Schedule (or Re-schedule) Post
posts.first.schedule!(7.day.from_now) # => true or raise exception
# Cancel Current Post Schedule
posts.first.unschedule! # => true or raise exception
# Publish Immediately
posts.first.publish! # => true or raise exception
NOTE:
Unpublishing posts is not allowed.
This means that once you published a page post accidentally, you have to ask the page owner to unpublish it manually.
And of course, you can’t schedule already published posts.