function fb_admin_token_info in Drupal for Facebook 7.4
Display detailed information about a token.
TODO: more detail, including extended perms.
2 calls to fb_admin_token_info()
- fb_admin_replace_token_form in ./
fb.admin.inc - fb_post_admin_form in ./
fb_post.admin.inc - Post to Facebook settings form.
File
- ./
fb.admin.inc, line 15
Code
function fb_admin_token_info($token) {
$markup = array(
'#type' => 'markup',
'#prefix' => '<p>',
'#suffix' => '</p>',
);
if (!$token) {
return array(
'#markup' => t('There is no token configured.'),
) + $markup;
}
$tdata = db_query("SELECT * FROM {fb_token} WHERE access_token=:token", array(
':token' => $token,
))
->fetchAssoc();
$me = NULL;
$app = NULL;
if ($tdata) {
try {
$app = fb_graph($tdata['fba']);
$me = fb_graph($tdata['fbu']);
} catch (Exception $e) {
}
}
else {
$tdata = array(
'fba' => t('unknown'),
'fbu' => t('unknown'),
);
}
if (!$app || !$me) {
try {
$graph = fb_graph_batch(array(
'app',
'me',
), $token);
extract($graph);
} catch (exception $e) {
}
}
$args = array();
if ($app) {
$args['!app'] = l(fb_get_name($app), fb_get_link($app));
$args['!app_logo'] = $app['logo_url'];
}
else {
$args['!app'] = $tdata['fba'];
// Show number.
$args['!app_logo'] = '';
}
if ($me) {
$args['!me'] = l(fb_get_name($me), fb_get_link($me));
$args['!me_logo'] = "//graph.facebook.com/" . $me['id'] . '/picture';
}
else {
$args['!me'] = $tdata['fbu'];
$args['!me_logo'] = '';
}
$output[] = array(
'#markup' => t('<img src=!me_logo /> <img src=!app_logo /> Token has the privileges of !me, via the application !app.', $args),
) + $markup;
if (user_access(FB_PERM_ADMINISTER_TOKEN)) {
$output[] = array(
'#markup' => t('<a target=_blank href=!fb_url_token_debug>Debug this token on developers.facebook.com</a>.', array(
'!fb_url_token_debug' => url('https://developers.facebook.com/tools/debug/access_token', array(
'query' => array(
'q' => $token,
),
)),
)),
) + $markup;
}
return $output;
}