How to register user on ejabberd using php ?

I am working on ChattApp, I want to register users in PHP.
I google it but can't find correct solution.
Please help me.
Last updated:2/28/2018 9:05:34 PM

3 Answers

Sunil Singh
Sunil Singh

try this code 

$request = xmlrpc_encode_request('register', $param, (array('encoding' => 'utf-8')));
$context = stream_context_create(array('http' => array(
    'method' => 'POST',
    'header' => 'User-Agent: XMLRPC::Client mod_xmlrpc\r\n' .
                'Content-Type: text/xml\r\n' .
                'Content-Length: '.strlen($request),
    'content' => $request
$file = file_get_contents('', false, $context);
$response = xmlrpc_decode($file);
if (xmlrpc_is_fault($response)) {
    trigger_error('xmlrpc: $response[faultString] ($response[faultCode])');
} else {

Abdelhafid DAHHANI
Abdelhafid DAHHANI


hope you are well

it doesn't work for me this code !!

'message': 'User Notice: xmlrpc: Error -118\nA problem '{error,access_rules_unauthorized}' occurred executing the command register with arguments\n[{user,<<\'ok\'>>},{host,<<\'localhost\'>>},{password,<<\'ok\'>>}] (-118)',