| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* @file facebook_api.module
|
| 4 |
* It's the Facebook API, you can't hook into the facebook client without this.
|
| 5 |
*/
|
| 6 |
require_once('facebook_api_admin.inc');
|
| 7 |
|
| 8 |
/**
|
| 9 |
* Implementation of hook_help().
|
| 10 |
*/
|
| 11 |
function facebook_api_help($section) {
|
| 12 |
switch ($section) {
|
| 13 |
case 'admin/modules#description':
|
| 14 |
return t('Programatic API that allows Drupal modules to harness the awesome power of the Facebook API.');
|
| 15 |
}
|
| 16 |
}
|
| 17 |
|
| 18 |
function facebook_api_menu($may_cache) {
|
| 19 |
if ($may_cache) {
|
| 20 |
// The admin page
|
| 21 |
$items[] = array(
|
| 22 |
'path' => 'admin/settings/facebook_api',
|
| 23 |
'title' => t('Facebook API Settings'),
|
| 24 |
'access' => user_access('can access facebook apps'),
|
| 25 |
'callback' => 'drupal_get_form',
|
| 26 |
'callback arguments' => array('facebook_admin_settings_form')
|
| 27 |
);
|
| 28 |
}
|
| 29 |
|
| 30 |
return (array) $items;
|
| 31 |
}
|
| 32 |
|
| 33 |
// OBSOLETE: The below facebook_api_load_client() function isn't useful any more.
|
| 34 |
// function facebook_api_load_client() {
|
| 35 |
// global $facebook;
|
| 36 |
// if (!class_exists('Facebook')) {
|
| 37 |
// include(drupal_get_path('module', 'facebook_api') . '/client/facebook.php');
|
| 38 |
// }
|
| 39 |
//
|
| 40 |
// $facebook = new Facebook(variable_get('facebook_api_key', ''), variable_get('facebook_api_secret', ''));
|
| 41 |
//
|
| 42 |
// if ($facebook) {
|
| 43 |
// return true;
|
| 44 |
// }
|
| 45 |
//
|
| 46 |
// return false;
|
| 47 |
// }
|
| 48 |
|
| 49 |
/**
|
| 50 |
* Singleton helper function to get the Facebook object. You must request
|
| 51 |
* the object by reference, by doing $facebook =& facebook_get_facebook_object();
|
| 52 |
*/
|
| 53 |
function &facebook_get_facebook_object() {
|
| 54 |
static $facebook;
|
| 55 |
|
| 56 |
if (!isset($facebook)) {
|
| 57 |
extract(facebook_get_conf());
|
| 58 |
|
| 59 |
if (!class_exists('Facebook')) {
|
| 60 |
require_once drupal_get_path('module', 'facebook_api') . '/client/facebook.php';
|
| 61 |
}
|
| 62 |
|
| 63 |
$facebook = new Facebook(variable_get('facebook_api_key', ''), variable_get('facebook_api_secret', ''));
|
| 64 |
}
|
| 65 |
|
| 66 |
return $facebook;
|
| 67 |
}
|