<?php
$data = array('users'=>array(
array(
'username'=>'testusername1',
'password'=>'testpassword1',
'firstname'=>'test',
'lastname'=>'user',
'email'=>'testusername@fakemail.com'
)
));
$ch = curl_init("http://vps02.ouhk.edu.hk/~qess/webservice/rest/server.php?wstoken=f4dfb904d79777f22cafe3c7472b744c&wsfunction=core_user_create_users&moodlewsrestformat=json");
curl_setopt_array($ch,array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36", // who am i
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_POST => true, // i am sending post data
CURLOPT_POSTFIELDS => http_build_query($data), // this are my post vars
CURLOPT_SSL_VERIFYHOST => 0, // don't verify ssl
CURLOPT_SSL_VERIFYPEER => false, //
CURLOPT_VERBOSE => 1 //
));
var_dump(curl_exec($ch));
preferences:
29.78 ms | 402 KiB | 5 Q