You are here

private function FBAutopost::checkPagesAvailability in Facebook Autopost 7

Throws an exception if the selected page id is not among the authorized ones.

1 call to FBAutopost::checkPagesAvailability()
FBAutopost::publish in class/FBAutopost.php
Publishes content in the selected pages

File

class/FBAutopost.php, line 446

Class

FBAutopost
API class to handle common actions when autoposting This class uses FBAutopostException for error handling. Severity is passed resusing watchdog severity (See: http://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/watch...)

Code

private function checkPagesAvailability() {
  $page_id = $this
    ->getDestination();

  // Get fresh access tokens for the pages. We use the server side access
  // token and the account ID to retrieve them
  $pages = self::getPagesAccessTokens(variable_get('fb_autopost_account_id', 'me'), variable_get('fb_autopost_token', ''));

  // Check that the selected page is in the available list.
  if (!in_array($page_id, array_keys($pages)) && $page_id != 'me') {
    throw new FBAutopostException(t('Insufficient permissions to publish on page with id @id. Please check !config.', array(
      '@id' => $page_id,
      '!config' => l(t('your configuration'), 'admin/config/services/fbautopost'),
    )), FBAutopost::incorrect_param, WATCHDOG_ERROR);
  }
}