Base on help information:
Basic HTTP Authentication
All REST Endpoint are secured by Basic HTTP Authentication.
To access the endpoints is that required to send the Username and
Password of a Openfire Admin account in your header request.
E.g. Header: Authorization: Basic YWRtaW46MTIzNDU= (username: admin /
password: 12345)
Example for Jersey Client
Client c = Client.create(); c.addFilter(new HTTPBasicAuthFilter(user,
password));
POST /mucservice/chatrooms
Endpoint to create a new chat room.
Payload: Chatroom Return value: HTTP status 201 (Created)
Possible parameters
Parameter Parameter Type Description Default value
servicename @QueryParam The name of the Group Chat Service conference
Examples
Header: Authorization: Basic YWRtaW46MTIzNDU=
Header: Content-Type: application/xml
POST http://example.org:9090/plugins/mucservice/chatrooms
Payload Example 1 (required parameters):
global-1
global
Global Chat Room
PHP code will be (tested with MUCservice version 0.2.3 Openfire 3.10.0):
function createRoom($naturalName, $roomName, $description) {
$url = "http://localhost:9090/plugins/mucservice/chatrooms";
$data = "<chatRoom>
<naturalName>$naturalName</naturalName>
<roomName>$roomName</roomName>
<description>$description</description>
</chatRoom>";
$username = "admin";
$password = "12345";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PORT, "9090");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array('Content-Type: application/xml',
'Authorization: Basic '.base64_encode("$username:$password")));
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
echo "code " . $code;
print_r($res);
curl_close($ch);
}
createRoom("room", "room", "room");