Hello guys,
I want to add roster by programming, Actually i am working on PHP(Jommla CMS) and here i want to add roster by programming.
Please anyone can help me i am tired now…
I have added user by programming and it work for me and here is my code-
$userService = new UserServicePHP(‘curl’, ‘url’, ‘Secretkey’);
$response = $userService->query(‘add’, username, password, name, email);
class UserServicePHP {
private $mode = ‘’;
public $host = ‘’;
public $port = ‘’;
public $secret = ‘’;
public function __construct($mode, $host, $secret, $port=‘9090’) {
$this->mode = $mode;
$this->host = $host;
$this->secret = $secret;
$this->port = $port;
}
public function query($type, $username, $password = null, $name = null, $email = null, $groups = null) {
$url = $this->host . ‘:’ . $this->port
. ‘/plugins/userService/userservice?’
. ‘secret=’ . $this->secret
. ‘&type=’. $type
. ‘&username=’ . $username
. ‘&password=’ . $password
. ‘&name=’ . $name
. ‘&email=’ . $email
. ‘&groups=’ . $groups;
if($this->mode == ‘curl’) {
$result = $this->mode_curl($url);
}
if($this->mode == ‘fopen’) {
$result = $this->mode_fopen($url);
}
return $result;
}
public function mode_curl($url) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
public function mode_fopen($url) {
$fopen = fopen($url, ‘r’);
$data = fread($fopen, 1024);
fclose($fopen);
return $data;
}
}
?>
Thanks