function fb_devel_user_view in Drupal for Facebook 7.3
Implements hook_user_view().
File
- ./
fb_devel.module, line 722 - 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_view($account, $view_mode, $langcod) {
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',
'#markup' => "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',
'#markup' => 'access_token: ' . fb_get_token($fb, $fbu),
'#prefix' => '<p>',
'#suffix' => '</p>',
);
$account->content['fb_devel'][$fb_app->label]['graph'] = array(
'#type' => 'markup',
'#markup' => 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',
'#markup' => dprint_r($e, 1),
),
);
}
}
else {
$account->content['fb_devel'][$fb_app->label]['info'] = array(
'#type' => 'markup',
'#markup' => t('No mapping to a facebook account.'),
);
}
}
}
}