function fb_admin_token_select_validate in Drupal for Facebook 7.4
1 string reference to 'fb_admin_token_select_validate'
- fb_element_info in ./
fb.module - Implements hook_element_info().
File
- ./
fb.admin.inc, line 1489
Code
function fb_admin_token_select_validate($element, &$form_state) {
$token = NULL;
extract($form_state['fb']);
// $all_tokens
if (!empty($element['#value'])) {
extract($element['#value']);
// $fb_token_index
}
else {
$fb_token_index = -1;
}
if ($fb_token_index > 0) {
$token = $all_tokens[$fb_token_index]['access_token'];
// Confirm that the token works.
try {
$graph = fb_graph_batch(array(
'me',
'app',
), $token);
$form_state['fb_graph'] = $graph;
// @todo confirm selected token has required permissions, if any.
} catch (Exception $e) {
form_error($element['fb_token_index'], t('Could not validate token. %detail', array(
'%detail' => $e
->getMessage(),
)));
$token = NULL;
}
}
// Simplify form value.
form_set_value($element, $token, $form_state);
}