如何在PHP中从openfire中删除聊天室

时间:2016-08-31 08:10:46

标签: php rest openfire

我已经从openfire创建了一个聊天室知道我必须删除一个聊天室 来自openfire.for这个我在curl的帮助下使用REST api插件。 我试过下面的代码,但它不适用于此我也参考了 来自openfire的REST api插件的文档,但我没有得到我出错的地方,请指导我解决这个问题。

使用REST API插件删除聊天室的代码

<?php

        $url1 = "http://ipaddress:9090/plugins/restapi/v1/chatrooms";

        $data1 = "<chatroom>
    <roomname>test</roomname>
    <servicename>conference</servicename>
    </chatroom>";

        $username1 = "Adminconsoleusername";
        $password1 = "Adminconsolepassword";
        $ch1 = curl_init();
        curl_setopt($ch1, CURLOPT_URL, $url1);
        curl_setopt($ch1, CURLOPT_PORT, "9090");
        curl_setopt($ch1, CURLOPT_POST, 1);
        curl_setopt($ch1, CURLOPT_POSTFIELDS, $data1);
        curl_setopt($ch1, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
        curl_setopt($ch1, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', 'Authorization: Basic ' . base64_encode("$username1:$password1")));
        $code1 = curl_getinfo($ch1, CURLINFO_HTTP_CODE);
        curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
        //echo $code1;
        $res1 = curl_exec($ch1);
        //echo "code " . $code;
        echo $res1;
        print_r($res1);

        curl_close($ch1);

我也参考了REST api doc https://www.igniterealtime.org/projects/openfire/plugins/restapi/readme.html#examples-20

请帮帮我, 在此先感谢。

1 个答案:

答案 0 :(得分:0)

网址还应包含您要删除的聊天室。 例如$ url1 =&#34; http://ipaddress:9090/plugins/restapi/v1/chatrooms/testroom&#34 ;;

相关问题