User service plugin problem

HI everyone,

I have installed user service plugin version 2.0.2. In past I have installed this plugin and written code in php to register user in open fire and it was working fine, but recently we have re-installed open fire, I have again installed user service plugin and enabled it from server settings. and same php code is there but its not working and returning false. below is my code in php script,

$url = ‘’;

$headers = array(

“Content-Type: application/xml”,



$ch = curl_init();

curl_setopt( $ch, CURLOPT_URL, $url);

curl_setopt( $ch, CURLOPT_POST, true );

curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);

curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

curl_setopt( $ch, CURLOPT_POSTFIELDS, "<user><username>testing</username><password>1234</password><name>Test User</name><email></email></user>" );

$result = curl_exec($ch);


Can anyone helo me where i am doing anything wrong. Or is there anything I need to enable on server or any port or something other stuff?

What is the response HTTP code of your request?

If you set the security secret key, did you also enabled the UserService (same view)?

Hi Redeyes,

Thank you for your reply,

Yes we have enabled user service. when I did try with var_dump($result) I am getting bool(false) in response. Is there any other configuration am I missing on server?

There are only two things that need to be set (see screenshot)


Please also check the HTTP respince code (List of HTTP status codes - Wikipedia, the free encyclopedia))

You could use the Postman Rest Client and send directly your request (not from PHP) it provides more detailed response.

Hi Redeye,

Thank you for your reply,

I just tried with Postman Rest Client, and it works. I did pass all same parameters and headers. but when I am trying with same headers and parameters using following php code,

$url = '’;

$headers = array(“Content-Type: application/xml”,“Authorization: mysecret”,“Cache-Control:no-cache”);

$ch = curl_init();

curl_setopt( $ch, CURLOPT_URL, $url);

curl_setopt( $ch, CURLOPT_POST,true);

curl_setopt( $ch, CURLOPT_HTTPHEADER,$headers);

curl_setopt( $ch, CURLOPT_RETURNTRANSFER,true);

curl_setopt( $ch, CURLOPT_POSTFIELDS,'<user><username>testing</username><password>1234</password> <name>Test User</name><email></email></user>');

$result = curl_exec($ch);

print curl_error($ch);




I am getting following response,

Failed to connect to port 9090: Connection timed outarray(22) { [“url”]=> string(51) “” [“content_type”]=> NULL [“http_code”]=> int(0) [“header_size”]=> int(0) [“request_size”]=> int(0) [“filetime”]=> int(-1) [“ssl_verify_result”]=> int(0) [“redirect_count”]=> int(0) [“total_time”]=> float(62.367608) [“namelookup_time”]=> float(0.000222) [“connect_time”]=> float(0) [“pretransfer_time”]=> float(0) [“size_upload”]=> float(0) [“size_download”]=> float(0) [“speed_download”]=> float(0) [“speed_upload”]=> float(0) [“download_content_length”]=> float(-1) [“upload_content_length”]=> float(-1) [“starttransfer_time”]=> float(0) [“redirect_time”]=> float(0) [“certinfo”]=> array(0) { } [“redirect_url”]=> string(0) “” }

Can you please help, what am I doing wrong?

“timed out” seems to be a Firewall problem?

Can it be, that your php script have no access to 9090 port on host:

Hi Redeye,

Thank you for your reply,

I just tried with telnet 9090 and its working fine, but as you said might be php script have no access to server port, did I ask my server administrator to make any extra configuration on for firewall or so for accessing openfire using script?

I wrote the same routine than you, I suppose.

Try to adapt it, or use my cURL specs, and tell us what happen.

$url = “http://localhost:9090/plugins/userService/users”;

$xml = ’<?xml version="1.0" encoding="UTF-8" standalone="yes"?>






//open connection

$ch = curl_init();

//set the url, number of POST vars, POST data

curl_setopt($ch,CURLOPT_URL, $url);



curl_setopt($ch, CURLOPT_HTTPHEADER, array(

‘Authorization: secret’,

‘Content-Type: application/xml’


curl_setopt($ch, CURLOPT_POST, 1 );

curl_setopt($ch, CURLOPT_POSTFIELDS, $xml );

#curl_setopt($ch,CURLOPT_POSTFIELDSPOST, count($fields));

#curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

//execute post

$result = curl_exec($ch);

$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);

ob_start(); // outer buffer

#echo “Code: $http_status | Username: {$user[‘name’]}\n”;


//close connection


if ($http_status == 201) {

return true;


else return false;

I guess that the server where the php script runs have no access to to port 9090

Hi Redeye,

Thank you for your reply,

We did contact our server administrator but they said 9090 port is globally permitted so it can not have issue with firewall. Also they have mentions that

that this is an ec2 instance and we are hosting openfire and site on same server, server is running whm/cpanel with csf firewall, Is there any extra configuration is required for Amazon EC2 server?

Hi Alex,

thank you for your reply,

We tried with your above code but getting same response.

Hi Redeye,

Awaiting your response.

Thank you.

Hey Craig,

I guess that is nothing User service plugin related, because you said it works with Postman.

I just tried with Postman Rest Client, and it works.

It could be a problem with your php script or with the connection from where the php script run and the openfire server.

Hi Redeye,

PHP script is same as I have posted above, Did you find any thing wrong in that? Else we can ask our server team to check server configuration.

Thank you.