Hi, I have the soap server running on Drupal 6 and am able to send requests to it using soapUI and also via http://localhost/drupal-6.x/?q=admin/build/services. However, I can't seem to get a positive response to user.login. Can someone explain how the fields should be used: hash, domain_name, domain_time_stamp, nonce, sessid, username, password?

Thanks,
John

Comments

jpulles’s picture

Status: Active » Fixed

The solution can be found in the example at http://drupal.org/node/308629. Translated into PHP this makes something like:

function get_nonce($length) {
  $allowedCharacters = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789";
  $password = str_pad('', $length);
  for ($i = 0; $i < $length; $i++) {
    $password[$i] = $allowedCharacters[rand(0, strlen($allowedCharacters) - 1)];
  }
  return $password;
}

// unix timestamp
$timestamp = time();
// nonce
$nonce = get_nonce(10);

$domain = 'localhost'; // the domain in ?q=admin/build/services/keys
$func = 'user.login';

$key = 'a13b4b81e510c4c67163d7565edbbc85'; // the api key in ?q=admin/build/services/keys
$hash = hash_hmac('sha256', implode(';', array($timestamp, $domain, $nonce, $func)), $key);
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.