DrupalBin
Submit Code
About
Recent Posts
Code
10 sec
ago
admin settings not saving
1 hour 26 min
ago
Code
2 hours 9 min
ago
Code
2 hours 25 min
ago
more
Tags
CCK
drupal
fapi
jquery
menu
module
Panels
php
simpletest
test
theme
views
more tags
User login
Log in using OpenID:
What is OpenID?
Username:
*
Password:
*
Create new account
Request new password
Log in using OpenID
Cancel OpenID login
Home
Fix for multi page form
View
Download
Fix
This fix will not be saved to the database until you submit.
Summary:
Tags:
Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Source code:
*
function oauth_request_call(){ $form['#multistep'] = TRUE; //drupal_set_message('<pre>'. print_r(&$form_state, TRUE) .'</pre>'); $step = isset($form_state) ? $form_state['values']['step'] : 1; // store next strp in hidden field $form['step'] = array( '#type' => 'hidden', '#value' => $step + 1 ); drupal_set_message('<pre>'. print_r($step, TRUE) .'</pre>'); // indicator of step number $form['indicator'] = array( '#type' => 'fieldset', '#title' => t('Step @number', array('@number' => $step)), ); switch($step){ case 1: $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, ); break; //$form_state['values']['step'] = 2; } if($step == 2) { drupal_set_message('<pre>'. print_r($result_request->data, TRUE) .'</pre>'); $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, ); $form['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')), '#default_value' => 1, ); $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'), ); $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, ); $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, ); $form['auth_call'] = array( '#value' => t('OAuth Authentication Call'), '#type' => 'submit', '#weight' => 14, ); } if($step == 3){ $form['indicator']['endpoints']['access_url'] = array( '#title' => t('Access URL'), '#type' => 'textfield', '#weight' => 7, ); $form['access_call'] = array( '#value' => t('OAuth Access Token Call'), '#type' => 'submit', '#weight' => 15, ); } $form['indicator']['request_call'] = array( '#value' => t('Request Token Call'), '#title' => t('Make call to server'), '#type' => 'submit', '#weight' => 10, ); switch($step){ case 1: $form_state['values']['step'] = 2; break; case 2: $form['consumer_key'] = array( '#type' => 'hidden', '#value' => $form_values['consumer_key'], ); $form['consumer_secret'] = array( '#type' => 'hidden', '#value' => $form_values['consumer_secret'], ); $form['request_url'] = array( '#type' => 'hidden', '#value' => $form_values['request_url'], ); break; } return $form; } function oauth_request_call_submit($form, &$form_state){ $key = $form_state['values']['consumer_key']; $secret = $form_state['values']['consumer_secret']; $request_url = $form_state['values']['request_url']; if($form_state['values']['sig_method'] == 0){ $user_sig_method = 'HMAC-SHA1'; }elseif($form_state['values']['sig_method'] == 1){ $user_sig_method = 'PLAINTEXT'; }elseif($form_state['values']['sig_method'] == 2){ $user_sig_method = 'RSA-SHA1'; } $test_token = NULL; if ($user_sig_method) { $sig_method = $sig_methods[$user_sig_method]; print_r($sig_method); } $plaintext_method = new OAuthSignatureMethod_PLAINTEXT(); //right now doing just for PLAINTEXT $sig_method = $plaintext_method; $token = $form_state['values']['oauth_token']; $token_secret = $form_state['values']['oauth_token_secret']; //drupal_set_message('<pre>'. print_r($sig_method, TRUE) .'</pre>'); $test_consumer = new OAuthConsumer($key, $secret, NULL); if($form_state['values']['op'] == 'OAuth Authentication Call'){ $test_token = new OAuthConsumer($token, $token_secret); //$callback_url = "$base_url/client.php?key=$key&secret=$secret&token=$token&token_secret=$token_secret&endpoint=" . urlencode($endpoint); $callback_url = "$base_url/?q=admin/oauth/services"; $auth_url = $form_state['values']['auth_url'] . "/oauth_token=$token&oauth_callback=".urlencode($callback_url); //$result_auth = drupal_http_request($auth_url, $headers = array(), $method = 'GET', $data = NULL, $retry = 3); //drupal_set_message('<pre>'. print_r($auth_url, TRUE) .'</pre>'); drupal_redirect_form($form, $auth_url); }elseif($form_state['values']['op'] == 'OAuth Access Token Call'){ //drupal_set_message('<pre>'. print_r($form_state['values']['access_url'], TRUE) .'</pre>'); $test_token = new OAuthConsumer($form_state['values']['oauth_token'], $form_state['values']['oauth_token_secret']); $parsed = parse_url($form_state['values']['access_url']); $params = array(); parse_str($parsed['query'], $params); $acc_req = OAuthRequest::from_consumer_and_token($test_consumer, $test_token, "GET", $form_state['values']['access_url'], $params); $acc_req->sign_request($sig_method, $test_consumer, $test_token); $result_access = drupal_http_request($acc_req, $headers = array(), $method = 'GET', $data = NULL, $retry = 3); drupal_set_message('<pre>'. print_r($result_access->data, TRUE) .'</pre>'); //drupal_redirect_form($form, $acc_req); } if($form_state['values']['op'] == 'Request Token Call'){ $parsed = parse_url($request_url); $params = array(); parse_str($parsed['query'], $params); //drupal_set_message('<pre>'. print_r($test_consumer, TRUE) .'</pre>'); $req_req = OAuthRequest::from_consumer_and_token($test_consumer, NULL, "GET", $request_url, $params); $req_req->sign_request($sig_method, $test_consumer, NULL); //drupal_set_message('<pre>'. print_r($req_req, TRUE) .'</pre>'); //drupal_redirect_form($form, $req_req); //Header("Location: $req_req"); $result_request = drupal_http_request($req_req, $headers = array(), $method = 'GET', $data = NULL, $retry = 3); //drupal_set_message('<pre>'. print_r($form_state, TRUE) .'</pre>'); return $result_request; } }
Syntax highlighting mode:
ActionScript
ColdFusion
Diff
Drupal
Drupal 5
Drupal 6
HTML
Javascript
MySQL
PHP
Python
robots.txt
SQL
Text
Select the syntax highlighting mode to use.