function vkxp_admin_access_token_submit in VK CrossPoster 6.3
Same name and namespace in other branches
- 7.2 vkxp.admin.inc \vkxp_admin_access_token_submit()
Second step of getting access token.
File
- ./
vkxp.admin.inc, line 169 - vkxp.admin.inc Contains VKXP settings form.
Code
function vkxp_admin_access_token_submit($form, &$form_state) {
// Collect params for authorization.
// See http://vk.com/developers.php?oid=-1&p=%D0%90%D0%B2%D1%82%D0%BE%D1%80%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F_%D1%81%D0%B0%D0%B9%D1%82%D0%BE%D0%B2
$params = array();
$params['client_id'] = variable_get('vkxp_app_id', '');
$params['client_secret'] = variable_get('vkxp_app_secret', '');
$params['code'] = $form_state['values']['code'];
$params['redirect_uri'] = VKXP_ACCESS_TOKEN_REDIRECT_URI;
$data = vkxp_query('', $params, VKXP_ACCESS_TOKEN_URI);
$data = (array) $data;
// Access token was recieved.
if (!empty($data['access_token'])) {
$message = array(
'text' => t('Access token was successfully recieved.'),
'severity' => 'status',
);
_vkxp_watchdog($message);
variable_set('vkxp_access_token', $data['access_token']);
// Redirect user to the settings page.
$form_state['redirect'] = 'admin/settings/vkxp';
}
elseif (isset($data['error']) && isset($data['error_description'])) {
$message = array(
'text' => t('Access token was not recieved. Reason: %error', array(
'%error' => check_plain($data['error_description']),
)),
'severity' => 'error',
);
_vkxp_watchdog($message);
// Remove variable if user not allowed to get a new access token.
variable_del('vkxp_access_token');
}
return $form;
}