I am new to moodle, and trying to figure out how to use some web services. I found this code on another post and decided to try it, but I get a page not found as result. Anybody can help me out ?
Moodle is installed on my machine (localhost), and I am making the request from another server.
Here is my code:
<?php
$params = array(
'userids' => array(2),
'wsfunction' => 'moodle_user_get_users_by_id',
'wstoken' => '<token>'
);
$postdata = http_build_query($params);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://localhost/moodle/webservice/rest/server.php');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
$data = curl_exec($ch);
curl_close($ch);
print "<pre>";
var_dump($data);
print "</pre>";
?>