You are here

function vkxp_admin_access_token in VK CrossPoster 7.2

Same name and namespace in other branches
  1. 6.3 vkxp.admin.inc \vkxp_admin_access_token()

Form for recieving access token from VK.

1 string reference to 'vkxp_admin_access_token'
vkxp_menu in ./vkxp.module
Implements hook_menu().

File

./vkxp.admin.inc, line 134
vkxp.admin.inc Contains VKXP settings form.

Code

function vkxp_admin_access_token($form, &$form_state) {
  $html_id = drupal_html_id('access-token-form');
  $form['#prefix'] = '<div id="' . $html_id . '">';
  $form['#suffix'] = '</div>';

  // FIRST STEP.
  // Getting authorize code from VK.
  $params = array();
  $params['client_id'] = variable_get('vkxp_app_id');
  $params['scope'] = VKXP_AUTHORIZE_SCOPE;
  $params['redirect_uri'] = VKXP_AUTHORIZE_REDIRECT_URI;
  $params['response_type'] = VKXP_AUTHORIZE_RESPONSE_TYPE;
  $form['new_access_token'] = array(
    '#type' => 'fieldset',
    '#title' => t('Recieve new access token'),
    '#collapsible' => TRUE,
    '#collapsed' => variable_get('vkxp_access_token') ? TRUE : FALSE,
  );
  $form['new_access_token']['link'] = array(
    '#theme' => 'link',
    '#text' => t('Get code'),
    '#path' => VKXP_AUTHORIZE_URI,
    '#options' => array(
      'query' => $params,
      'html' => FALSE,
      'attributes' => array(
        'target' => '_blank',
      ),
    ),
  );
  $form['new_access_token']['code'] = array(
    '#type' => 'textfield',
    '#title' => t('Code'),
    '#description' => t('Copy #code param from the URL here.'),
  );
  $form['new_access_token']['actions'] = array(
    '#type' => 'action',
  );
  $form['new_access_token']['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Get access token'),
  );
  return $form;
}