×
Tips & Tricks
Please do NOT use this section of the forum to request help if Joomdle does not work for you in some particular way. Your post will be deleted.
Please do NOT use this section of the forum to request help if Joomdle does not work for you in some particular way. Your post will be deleted.
How to call joomdle web service functions in my own service
10 years 3 months ago
10 years 3 months ago by Alex.
Topic Author
How to call joomdle web service functions in my own service #1
Hi, i'm trying to call joomdle_get_moodle_users from my service in this way... but there is something wrong, could anyone help me? thanks
function getAllMoodleUser($limitstart) {
$this->error = null;
// Create XML for the request. XML must be set properly for this to work.
$request = xmlrpc_encode_request('joomdle_get_moodle_users', (int)$limitstart);
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => $request
)));
$path = $this->server.$this->dir."/webservice/xmlrpc/server.php?wstoken=".$this->token;
// Send XML to server and get a reply from it.
$file = file_get_contents($path, false, $context); // $file is the reply from server.
// Decode the reply.
$response = xmlrpc_decode($file);
return $response;
}
my goal is get the list of all moodle users
function getAllMoodleUser($limitstart) {
$this->error = null;
// Create XML for the request. XML must be set properly for this to work.
$request = xmlrpc_encode_request('joomdle_get_moodle_users', (int)$limitstart);
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => $request
)));
$path = $this->server.$this->dir."/webservice/xmlrpc/server.php?wstoken=".$this->token;
// Send XML to server and get a reply from it.
$file = file_get_contents($path, false, $context); // $file is the reply from server.
// Decode the reply.
$response = xmlrpc_decode($file);
return $response;
}
my goal is get the list of all moodle users
Please Log in or Create an account to join the conversation.
10 years 3 months ago
How to call joomdle web service functions in my own service #2
Are you calling this inside Joomla, or in a external script? If in Joomla, you could just use the Joomdle wrapper functions to make web service calls.
If not, what problem are you having?
If not, what problem are you having?
Please Log in or Create an account to join the conversation.
10 years 3 months ago
Topic Author
How to call joomdle web service functions in my own service #3
hi, i'm trying to call from an external scritp
Please Log in or Create an account to join the conversation.
10 years 3 months ago
Topic Author
How to call joomdle web service functions in my own service #4
first of all, is that the right way to call this function?
Please Log in or Create an account to join the conversation.
10 years 3 months ago
10 years 3 months ago by Alex.
Topic Author
How to call joomdle web service functions in my own service #5
I've also tryied with
$request = xmlrpc_encode_request('joomdle_get_moodle_users', array('limitstart' =>0, 'limit' => 5, 'order' => 'desc', 'order_dir' => '', 'search' => ''),array('encoding'=>'UTF-8'));
but this doesn't work.... moreover i don't know the correct values for 'order', 'order_dir' and 'search' text fields
The problem is that the response is
array (size=2)
'faultCode' => int 404
'faultString' => string 'Unknown error' (length=13)
null
$request = xmlrpc_encode_request('joomdle_get_moodle_users', array('limitstart' =>0, 'limit' => 5, 'order' => 'desc', 'order_dir' => '', 'search' => ''),array('encoding'=>'UTF-8'));
but this doesn't work.... moreover i don't know the correct values for 'order', 'order_dir' and 'search' text fields
The problem is that the response is
array (size=2)
'faultCode' => int 404
'faultString' => string 'Unknown error' (length=13)
null
Please Log in or Create an account to join the conversation.
10 years 3 months ago
How to call joomdle web service functions in my own service #6
Your values seem correct,
Enabled debugging in Moodle to get more info about the 404.
Enabled debugging in Moodle to get more info about the 404.
Please Log in or Create an account to join the conversation.
10 years 3 months ago
Topic Author
How to call joomdle web service functions in my own service #7
i took a look to the implementation of get_moodle_users() in auth.php script.
it take these parameters and build an sql query... my request is
$request = xmlrpc_encode_request('joomdle_get_moodle_users',array('limitstart' =>0, 'limit' => 5, 'order' => 'name', 'order_dir' => 'desc', 'search' => ''),array('encoding'=>'utf8'));
and the error is: "parameters do not match signature | ERRORCODE: 1"
it take these parameters and build an sql query... my request is
$request = xmlrpc_encode_request('joomdle_get_moodle_users',array('limitstart' =>0, 'limit' => 5, 'order' => 'name', 'order_dir' => 'desc', 'search' => ''),array('encoding'=>'utf8'));
and the error is: "parameters do not match signature | ERRORCODE: 1"
Please Log in or Create an account to join the conversation.
10 years 3 months ago
How to call joomdle web service functions in my own service #8
You may need to force types, with something like: (int) 0
Please Log in or Create an account to join the conversation.
10 years 3 months ago
Topic Author
How to call joomdle web service functions in my own service #9
thanks but it still doesn't work
$request = xmlrpc_encode_request('joomdle_get_moodle_users',array('limitstart' => (int)0, 'limit' => (int)5, 'order' => (string)'name', 'order_dir' => (string)'', 'search' => (string)''),array('encoding'=>'utf8'));
$request = xmlrpc_encode_request('joomdle_get_moodle_users',array('limitstart' => (int)0, 'limit' => (int)5, 'order' => (string)'name', 'order_dir' => (string)'', 'search' => (string)''),array('encoding'=>'utf8'));
Please Log in or Create an account to join the conversation.
10 years 3 months ago
How to call joomdle web service functions in my own service #10
There is no "name" field in moodle user table. Try "lastname".
Please Log in or Create an account to join the conversation.