5 Replies Latest reply on Jun 1, 2015 12:33 AM by vijay

    programmatically add roster items and users

    chiodi84 Bronze


      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

        • Re: programmatically add roster items and users
          Daryl Herzmann KeyContributor



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



          1 of 1 people found this helpful
          • Re: programmatically add roster items and users
            vijay Bronze

            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;