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 


$param=array('user'=>'testusername','host'=>'testserver.com','password'=>'test');
$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('http://192.168.1.199:4560/', false, $context);
$response = xmlrpc_decode($file);
if (xmlrpc_is_fault($response)) {
    trigger_error('xmlrpc: $response[faultString] ($response[faultCode])');
} else {
    print_r($response);
}

Abdelhafid DAHHANI
Abdelhafid DAHHANI

Hii

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)',

Answer