You are here

function _load_facebook_sdk in Facebook Autopost 7

Helper function to load the facebook php sdk library.

Parameters

string $basename: Optional basename where to find the library

Throws

Exception

1 call to _load_facebook_sdk()
FBAutopost.php in class/FBAutopost.php

File

./fb_autopost.module, line 201
Module implementation file

Code

function _load_facebook_sdk($basename = NULL) {
  $lib_path = libraries_get_path('facebook-php-sdk', $basename);
  if (!file_exists($lib_path . '/src/facebook.php')) {

    // In case we cannot find the file display an error and redirect to the
    // report status page (if the user can access it).
    if (user_access('view site reports')) {
      drupal_set_message(t('You need to install the !library to use the Facebook Autopost module. Please download the library to sites/all/libraries/facebook-php-sdk.', array(
        '!library' => l(t('Facebook PHP Library'), 'https://github.com/facebook/facebook-php-sdk', array(
          'attributes' => array(
            'target' => '_blank',
          ),
        )),
      )), 'error');
      drupal_goto('admin/reports/status');
    }
    else {

      // The user cannot see the site reports with further instructions
      // throw an Exception.
      throw new FBAutopostException(t('Facebook Autopost could not be started because the Facebook PHP library is missing. Please contact system administration to communicate this error.'));
    }
  }
  else {
    require_once $lib_path . '/src/facebook.php';
  }
}