You are here

public function FBAutopost::getPagesData in Facebook Autopost 7

Gets the reply given from Facebook when asking for user account.

Parameters

$account_id: User account asked for

$account_access_token: Server side access token stored from the admin form.

Return value

The array from the Graph API call

Throws

FBAutopostException

File

class/FBAutopost.php, line 297

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

public function getPagesData($account_id, $account_access_token) {

  // Check if there is an access_token available.
  if (empty($account_access_token)) {
    throw new FBAutopostException(t('Cannot ask for user accounts without an access token.'), FBAutopost::missing_param, WATCHDOG_ERROR);
  }
  try {
    return $this
      ->api('/' . $account_id . '/accounts', 'GET', array(
      'limit' => 999,
    ));
  } catch (FacebookApiException $e) {

    // Get the FacebookApiException and throw an ordinary
    // FBAutopostException
    throw new FBAutopostException(t('Facebook SDK threw an error: %error It is possible that your Facebook account cannot access the configured pages, if so please log in again in !url.', array(
      '%error' => $e,
      '!url' => l(t('Facebook autopost configuration page'), 'admin/config/services/fbautopost'),
    )), FBAutopost::sdk_error, WATCHDOG_ERROR);
  }
}