Update user data using web services

Update user data using web services

by Martí Vallejo Noguer -
Number of replies: 3

Hello everyone, 

I'm using moodle v2.0 and I'm trying to update a concrete user's data using a webservice in php. The main problem is that I've been looking for information through the internet and since I'm new at this, (moodle) I don't know exactly how to manage it.

I've been trying with conduit webservice, but I don't get exactly how to make it work.

The main question would be: If I want to update the username of a user using a webservice in php, which is the right (and easiest) way to do it? There is any tutorial easy to understand with this kind of examples?

Thank you very much. 

Average of ratings: -
In reply to Martí Vallejo Noguer

Re: Update user data using web services

by john saylor -

in 2.4 there's a new webservice function:
core_users_update_user
which is probably exactly what you need.

If you can't update to this version, perhaps you can integrate this code into your site by hand- this is somewhat risky and error-prone operation, but it might be your only option.

good luck!

 

In reply to john saylor

Re: Update user data using web services

by Martí Vallejo Noguer -

Thanks for the answer!

I've tried to use this web service and after configurating it all I've got some problems, 

this is the code:

$params['users'][0]['id']="68";
$params['users'][0]['city']="NY";

$client = new Zend_Http_Client('<my domain>/webservice/rest/server.php');
$client->setParameterPost(array('token'=>'<my token>','method'=>'core_user_update_users','users'=>$params));
$response = $client->request('POST');
$lastrequest = $client->getLastRequest();

file_put_contents('php://stderr', "\n lastrequest: ".$lastrequest);
file_put_contents('php://stderr', "\n response: ".$response);

Using this code everything seems to work, it doesnt' display any error message but it doesn't update at all... 

Can you give me any clue of why is this happenning? Thank you very much!

In reply to Martí Vallejo Noguer

Re: Update user data using web services

by Ramchadnra Pujari -

Marti, have you get any opprtunity to solve this issue am also waiting for replay.

Thank you