I have been trying to use the Services Browser at http://www.example.com/admin/build/services/browse/user.save to figure out how to provision a user. The idea is to login to an account that is allowed to create users from a device like an iPhone or Android. Get the user information and away we go.
But I have been having trouble formatting the request.
Sending the parameter as serialized PHP :
stdClass Object ([name] =>'jazzMaster1', [pass] => 'test', [mail] => 'jazzMaster1@example.com' });
or:
stdClass Object ([username] =>'jazzMaster1', [password] => 'test', [e-mail] => 'jazzMaster1@example.com' });
I get :
* Username field is required.
* Password field is required.
* You must enter an e-mail address.
The output of the code suggested on http://drupal.org/node/467786
$obj = (object)array(
'name' =>'jazzMaster1','pass' => 'test','mail' => 'jazzMaster1@example.com'
);
print serialize($obj)."\n";
This crashes the server:
O:8:"stdClass":3:{s:4:"name";s:11:"jazzMaster1";s:4:"pass";s:4:"test";s:4:"mail";s:23:"jazzMaster1@example.com";}
However adding "(" ... ");" is OK:
(O:8:"stdClass":3:{s:4:"name";s:11:"jazzMaster1";s:4:"pass";s:4:"test";s:4:"mail";s:23:"jazzMaster1@example.com";});
But, I get :
* Username field is required.
* Password field is required.
* You must enter an e-mail address.
Does any wizard know how to provision an account with user.save in the services module?
Comments
Comment #1
sasconsul commentedComment #2
marcingy commentedSetting priority correctly.
Comment #3
gddI helped sasconsul with this on IRC. One problem here is that the documentation of the service states that it expects an object, when in fact it expects an array. We should change that in the next release of 2.x (if there is one.) It should accept an object, just as user_save() does.
A properly serialized array like
a:3:{s:4:"name";s:3:"foo";s:4:"pass";s:3:"bar";s:4:"mail";s:11:"foo@bar.com";}
worked fine for him.
Comment #4
sasconsul commentedOk Folks, got it with the help of heyrocker on irc.
This serialized PHP works in the browser:
The code you test in the Services browser must fit into the text field of the Services Browser!
Comment #5
marcingy commentedThis is not critical.....
Comment #6
marcingy commented