XEP 0133 – Service Administration available methods in Jaxl 2.0

Standard

Jaxl 2.0 implements more than 10 XMPP extensions including XEP-0133 a.k.a. Service Administration. In this blog post, we will go through all the methods available for use in XMPP applications developed using Jaxl.

Using Service administration methods
You need to include Jaxl implementation of XEP-0133 in your application code to start using below listed available methods. Here is how this can be done at the top of your application code:

// initialize jaxl instance
$jaxl = new JAXL();

// include service administration
$jaxl->requires('JAXL0133'); // or jaxl_require('JAXL0133', $jaxl);

Service administration available methods
Below is a detailed list of methods from service administration extension:

  • $jaxl->JAXL0133(‘addUser’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘deleteUser’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘disableUser’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘reEnableUser’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘endUserSession’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘getUserPassword’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘changeUserPassword’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘getUserRoster’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘getUserLastLoginTime’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘getUserStatistics’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘editBlacklist’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘editWhitelist’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘getUserCount’, $user, $domain, $callback, $type)
  • $jaxl->JAXL0133(‘getUserList’, $user, $domain, $callback, $type)
  • $jaxl->JAXL0133(‘sendAnnouncementToActiveUsers’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘setMOTD’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘editMOTD’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘deleteMOTD’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘setWelcomeMessage’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘deleteWelcomeMessage’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘editAdminList’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘restartService’, $user, $domain, $callback)
  • $jaxl->JAXL0133(‘shutdownService’, $user, $domain, $callback)

Examples
All the methods expects 3 parameters as defined below:

  • $user: An associative array containing information about the user on whose account service administrative actions need to be taken
  • $domain: Jabber domain to which $user belongs
  • $callback: Specify where do you want to receive success/failure of executed service administration command
  • $type: Required by getUserCount and getUserList methods. Allowed values are registered, disabled, online, active and idle.

$user array MUST correspond to the fields in the request form for executing service administration commands.

Here is how to add a new user using XEP-0133:

$user = array(
        'jid' => 'newuser',
        'pass' => 'password',
        'email' => 'newuser@email.com',
        'fname' => 'Hello',
        'lname' => 'World'
);

$jaxl->JAXL0133('addUser', $user, 'jaxl.im', array($this, 'postAddUser'));

Your application code must have a methods named ‘postAddUser’ which will be called back by Jaxl core, when it finishes executing the command.