You are here

function oauth_request_call in OAuth 1.0 6

1 string reference to 'oauth_request_call'
oauth_test_calls in ./oauth.module
this function is to make test calls to any oauth server for producing oauth tokens corresponding to your keys and secret

File

./oauth.module, line 488

Code

function oauth_request_call($form_state) {
  if (!$_SESSION['oauth']['operation']) {
    $_SESSION['oauth']['operation'] = 'request';
  }

  // indicator of step number
  $form['indicator'] = array(
    '#type' => 'fieldset',
    '#title' => t('Step @number', array(
      '@number' => $_SESSION['oauth']['operation'],
    )),
  );
  if ($_SESSION['oauth']['operation'] == 'request') {
    $form['indicator']['consumer'] = array(
      '#type' => 'fieldset',
      '#title' => t('consumer details'),
    );
    $form['indicator']['consumer']['consumer_key'] = array(
      '#title' => t('consumer key'),
      '#description' => t('consumer key of user on test server'),
      '#type' => 'textfield',
    );
    $form['indicator']['consumer']['consumer_secret'] = array(
      '#title' => t('consumer secret'),
      '#description' => t('consumer secret of user on test server'),
      '#type' => 'textfield',
    );
    $form['indicator']['endpoints'] = array(
      '#title' => t('end points of testing server'),
      '#type' => 'fieldset',
    );
    $form['indicator']['endpoints']['request_url'] = array(
      '#title' => t('Request URL'),
      '#type' => 'textfield',
      '#weight' => 5,
      '#default_value' => 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'] . '?q=oauth/request',
    );
    $form['indicator']['signature_method'] = array(
      '#title' => t('Select Signature Method'),
      '#type' => 'fieldset',
    );
    $form['indicator']['signature_method']['indicator']['sig_method'] = array(
      '#title' => t('Please select signature method to use'),
      '#type' => 'radios',
      '#options' => array(
        0 => t('HMAC-SHA1'),
        1 => t('PLAINTEXT'),
        2 => t('RSA-SHA1'),
      ),
      '#weight' => 9,
    );
    $form['indicator']['request_call'] = array(
      '#value' => t('Request Token Call'),
      '#title' => t('Make call to server'),
      '#type' => 'submit',
      '#weight' => 10,
    );
  }
  if ($_SESSION['oauth']['operation'] == 'auth') {
    $form['indicator']['endpoints'] = array(
      '#title' => t('end points of testing server'),
      '#type' => 'fieldset',
    );
    $form['indicator']['endpoints']['auth_url'] = array(
      '#title' => t('Authentication URL'),
      '#type' => 'textfield',
      '#weight' => 6,
      '#default_value' => 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'] . '?q=oauth/auth',
    );
    $form['indicator']['token'] = array(
      '#type' => 'fieldset',
      '#title' => t('Token and Token secret'),
      '#description' => t('Paste Token and Token Secret from above which are obtained after request call'),
      '#weight' => 11,
    );
    $form['indicator']['token']['oauth_token'] = array(
      '#title' => t('OAuth token'),
      '#description' => t('Please paste token from above which you obtain from request call'),
      '#type' => 'textfield',
      '#weight' => 12,
      '#default_value' => $form_state['data']['oauth_token'],
    );
    $form['indicator']['token']['oauth_token_secret'] = array(
      '#title' => t('OAuth token secret'),
      '#description' => t('Please paste token secret from above which you obtain from request call'),
      '#type' => 'textfield',
      '#weight' => 13,
      '#default_value' => $form_state['data']['oauth_token_secret'],
    );
    $form['indicator']['auth_call'] = array(
      '#value' => t('OAuth Authentication Call'),
      '#type' => 'submit',
      '#weight' => 14,
    );
  }
  if ($_SESSION['oauth']['operation'] == 'access') {
    $form['indicator']['endpoints']['access_url'] = array(
      '#title' => t('Access URL'),
      '#type' => 'textfield',
      '#weight' => 7,
      '#default_value' => 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'] . '?q=oauth/access',
    );
    $form['indicator']['access_call'] = array(
      '#value' => t('OAuth Access Token Call'),
      '#type' => 'submit',
      '#weight' => 15,
    );
  }
  switch ($_SESSION['oauth']['operation']) {
    case auth:
      $form['consumer_key'] = array(
        '#type' => 'hidden',
        '#value' => $form_state['values']['consumer_key'],
      );
      $form['consumer_secret'] = array(
        '#type' => 'hidden',
        '#value' => $form_state['values']['consumer_secret'],
      );
      $form['request_url'] = array(
        '#type' => 'hidden',
        '#value' => $form_values['request_url'],
      );
      break;
  }
  $form['back'] = array(
    '#value' => t('Back To Request Token Page'),
    '#type' => 'submit',
    '#weight' => 17,
  );
  return $form;
}