Programmatically add roster items and users


i’m creating an application that interact with openfire jabber server.

my application have to programmatically create Users, RosterItems…

I use a postgresql database and create Users and RosterItems directly on the database.

The problem is that openfire has cached data and the changes won’t take effect until server restarts.

Is there any way to force cache renewal, or a better way to add Users and RosterItems etc without writing directly on db?

Thank you in advance

Paolo Chiodi


Check out the UserService plugin, it will help you accomplish some of what you want.


thank you for your answer.

i was really looking for something like that plugin, but i need some more functionality

maybe i’ll evaluate the possibility to write my own plugin

Paolo Chiodi

Hi! I’ve got the same task - to control (add/edit/delete) users and user’s roster from outside. As you’ve mentioned above, user controlling can be particulary performed via userService plugin, but there’s no way to manipulate with user’s roster. It seems, that we aslo have to create such plugin by ourselves

May be this will be helpful for someone. To manage user’s roster, please see

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);


return $data;


public function mode_fopen($url) {

$fopen = fopen($url, ‘r’);

$data = fread($fopen, 1024);


return $data;