You are here

function simple_fb_connect_facebook_client_load_include in Simple FB Connect 8

Same name and namespace in other branches
  1. 7 simple_fb_connect.module \simple_fb_connect_facebook_client_load_include()

Locates and loads the Facebook PHP SDK library.

1 call to simple_fb_connect_facebook_client_load_include()
facebook_client in ./simple_fb_connect.module
Get the facebook client object for easy access.

File

./simple_fb_connect.module, line 60
Simple Facebook Login Module for Drupal Sites.

Code

function simple_fb_connect_facebook_client_load_include() {
  if (!class_exists('Facebook')) {
    if (function_exists('libraries_load')) {
      $library = libraries_load('facebook-php-sdk');
    }
    else {
      $sdk_path = DRUPAL_ROOT . '/sites/all/libraries/facebook-php-sdk/src/facebook.php';
      $library = array(
        'loaded' => file_exists($sdk_path),
      );
      if ($library['loaded']) {
        require_once $sdk_path;
      }
    }
    if (!$library['loaded']) {
      watchdog('simple_fb_connect', 'Unable to load the required Facebook library');
      drupal_set_message(t('Facebook Library not found - ' . $library['error message']), 'error');
    }
  }
  return class_exists('Facebook') && defined('Facebook::VERSION');
}