function fb_devel_user in Drupal for Facebook 6.3
Same name and namespace in other branches
- 6.2 fb_devel.module \fb_devel_user()
Implements hook_user().
File
- ./
fb_devel.module, line 702 - Makes development with Drupal for Facebook much easier. Keep this module enabled until you're confident your app works perfectly.
Code
function fb_devel_user($op, &$edit, &$account, $category = NULL) {
if ($op == 'view') {
if (user_access('administer users') && user_access('access devel information')) {
$account->content['fb_devel'] = array(
'#type' => 'fieldset',
'#title' => t('Drupal for Facebook Devel'),
'#description' => t('Information from facebook API, visible only to administrators.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 99,
);
foreach (fb_get_all_apps() as $fb_app) {
$account->content['fb_devel'][$fb_app->label] = array(
'#type' => 'fieldset',
'#title' => $fb_app->title,
);
if ($fbu = fb_get_fbu($account, $fb_app)) {
$fb = fb_api_init($fb_app);
try {
// Don't use fb_api() because we don't want the caching here.
$info = $fb
->api("/{$fbu}", array(
'access_token' => fb_get_token($fb),
));
//$info = fb_users_getInfo(array($fbu), $fb, TRUE);
$account->content['fb_devel'][$fb_app->label]['info'] = array(
'#type' => 'markup',
'#value' => "facebook graph for /{$fbu}:" . dprint_r($info, 1),
);
if ($token = fb_get_token($fb, $fbu)) {
$account->content['fb_devel'][$fb_app->label]['token'] = array(
'#type' => 'markup',
'#value' => 'access_token: ' . $token,
'#prefix' => '<p>',
'#suffix' => '</p>',
);
$account->content['fb_devel'][$fb_app->label]['graph'] = array(
'#type' => 'markup',
'#value' => l(t('Browse graph as this user'), 'https://graph.facebook.com/' . $fbu . '?metadata=1&access_token=' . $token),
'#prefix' => '<p>',
'#suffix' => '</p>',
);
}
} catch (Exception $e) {
$account->content['fb_devel'][$fb_app->label]['#description'] = $e
->getMessage();
$account->content['fb_devel'][$fb_app->label]['info'] = array(
'#type' => 'fieldset',
'#title' => t('Failed to get info for !app.', array(
'!app' => $fb_app->title,
)),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'exception' => array(
'#type' => 'markup',
'#value' => dprint_r($e, 1),
),
);
}
}
else {
$account->content['fb_devel'][$fb_app->label]['info'] = array(
'#type' => 'markup',
'#value' => t('No mapping to a facebook account.'),
);
}
}
}
}
}