I tested with node.get and it returns the node beautifully. However, when I try to use the user.login method it always returns the following:

Error 5: Didn't receive 200 OK from remote server. (HTTP/1.1 302 Found)

Here is the code I am using to try and access the xmlrpc server:

// API key as generated in the Services "Keys" page
$key = '000000000000000000000000000000000';

//domain which you authorized to use this key in the Services "Keys" page
$domain = 'http://www.domain.com';
$method = 'user.login';
// create client
$client = new xmlrpc_client('/services/xmlrpc', 'xmlrpc.server.com', 80);

// get a session id
// this is necessary unless you have unchecked the "use sessid" box on the Services "Settings" page
if ($use_sessid) {
$message = new xmlrpcmsg('system.connect',array());
$resp = $client->send($message);
$data = rpcexample_rpc_convert($resp->value());
$sessid = $data['sessid'];
}
	
$timestamp = (string) time();
$nonce = user_password();
$hash = hash_hmac('sha256', $timestamp.';'.$domain.';'.$nonce.';'.$method, $key);
$params = array(
new xmlrpcval($hash,'string'),
new xmlrpcval($domain,'string'),
new xmlrpcval($timestamp,'string'),
new xmlrpcval($nonce,'string'),
new xmlrpcval($sessid,'string'),
);
	
$params[] = new xmlrpcval('username','string');
$params[] = new xmlrpcval('password','string');
 
$message = new xmlrpcmsg($method,$params);
$resp = $client->send($message);
$data = rpcexample_rpc_convert($resp->value());
if ($data) {
print_r($data);
} else {
//print_r($resp);
print("Error $resp->errno: $resp->errstr\n");
}

In the above code, I replaced all correct domain and key info with dummy data. However, the code on my server has the correct info (I triple checked).

Any help would be greatly appreciated.

Comments

tim_ftw’s picture

Status: Active » Closed (fixed)

I figured out what my problem was. Apparently someone had put in a hand-coded redirect by using the hook_user function. Once I found it, I was able to disable it for anything using the services. now it works like a champ!

sanjith’s picture

hi,

How we can skip the redirect for the services module ?

I am working on a multisite using drupal 6.
The site works like
use1.domain.com
user2.domain.com

the main site is domain.com

If the user logs in, he will be redirected to his domain

Thanks in advance
SVN

sanjith’s picture

Thanks lot, fixed the issue

ericpai’s picture

Issue tags: +xmlrpc redirect fix

Same problem here with the redirect. I realized I had an action and a trigger set up so when a user logs in, it sends them to a welcome page.
I disable the trigger and now my user.login xmlrpc connection works!
The problem is, I need that redirect working. So is there a way to fix this?

thanks

Update:
Temporary solution until triggers or services gets fixed:
I had to disable my trigger and do the redirect in a custom module instead. My module is called "form_mods"

function form_mods_user ( $op ){
    if ( $op == "login" ){
    $_REQUEST['destination'] = 'welcome';
    }
}