如何使用XMPPHP在Openfire中创建会议室?

如何使用XMPPHP在Openfire中创建会议室?,xmpp,openfire,xmpphp,Xmpp,Openfire,Xmpphp,我正在开发一个系统,在某个时候,我必须允许用户创建自己的会议室 我正在阅读有关XMPP的文章,并编写了一些代码,这些代码会导致下面的详细日志 1422017436 [VERBOSE]: Socket is ready; send it. 1422017436 [VERBOSE]: SENT: <presence from='24527@localhost/xmpphp' to='sala3@myconference.localhost/xmpphp'><x xmlns='htt

我正在开发一个系统,在某个时候,我必须允许用户创建自己的会议室

我正在阅读有关XMPP的文章,并编写了一些代码,这些代码会导致下面的详细日志

1422017436 [VERBOSE]: Socket is ready; send it.
1422017436 [VERBOSE]: SENT: <presence from='24527@localhost/xmpphp' to='sala3@myconference.localhost/xmpphp'><x xmlns='http://jabber.org/protocol/muc'/></presence>
1422017436 [VERBOSE]: Successfully sent 134 bytes.
1422017436 [VERBOSE]: Socket is ready; send it.
1422017436 [VERBOSE]: SENT: <iq from='24527@localhost/xmpphp' id='create1' to='sala3@myconference.localhost/xmpphp' type='set'><query xmlns='http://jabber.org/protocol/muc#owner'><x xmlns='jabber:x:data' type='submit'/></query></iq>
1422017436 [VERBOSE]: Successfully sent 203 bytes.
1422017436 [VERBOSE]: Disconnecting...
1422017436 [VERBOSE]: Socket is ready; send it.
1422017436 [VERBOSE]: SENT: </stream:stream>
1422017436 [VERBOSE]: Successfully sent 16 bytes.
1422017436 [VERBOSE]: RECV: <presence from="sala3@myconference.localhost/xmpphp" to="24527@localhost/xmpphp"><x xmlns="http://jabber.org/protocol/muc#user"><item jid="24527@localhost/xmpphp" affiliation="owner" role="moderator"/><status code="110"/><status code="100"/><status code="201"/></x></presence>
1422017436 [DEBUG]: Calling presence_handler
1422017436 [DEBUG]: Presence: sala3@myconference.localhost/xmpphp [available] 
1422017436 [DEBUG]: EVENT: presence
1422017436 [VERBOSE]: RECV: <iq type="result" id="create1" from="sala3@myconference.localhost/xmpphp" to="24527@localhost/xmpphp"/>
1422017436 [VERBOSE]: RECV: </stream:stream>
1422017436 [DEBUG]: EVENT: end_stream
1422017436[VERBOSE]:套接字已就绪;发送它。
1422017436[详细]:已发送:
1422017436[详细]:已成功发送134字节。
1422017436[详细]:套接字已准备就绪;发送它。
1422017436[详细]:已发送:
1422017436[详细]:已成功发送203字节。
1422017436[详细]:断开连接。。。
1422017436[详细]:套接字已准备就绪;发送它。
1422017436[详细]:已发送:
1422017436[详细]:已成功发送16个字节。
1422017436[详细]:记录:
1422017436[调试]:调用状态\处理程序
1422017436[调试]:状态:sala3@myconference.localhost/xmpphp[可用]
1422017436[调试]:事件:存在
1422017436[详细]:记录:
1422017436[详细]:记录:
1422017436[调试]:事件:结束\u流
正如我在这里看到的那样,它似乎起了作用:

1422017436 [DEBUG]: Calling presence_handler
1422017436 [DEBUG]: Presence: sala3@myconference.localhost/xmpphp [available] 
1422017436 [DEBUG]: EVENT: presence
1422017436 [VERBOSE]: RECV: <iq type="result" id="create1" from="sala3@myconference.localhost/xmpphp" to="24527@localhost/xmpphp"/>
1422017436 [VERBOSE]: RECV: </stream:stream>
1422017436[DEBUG]:调用状态处理程序
1422017436[调试]:状态:sala3@myconference.localhost/xmpphp[可用]
1422017436[调试]:事件:存在
1422017436[详细]:记录:
1422017436[详细]:记录:
但是我在Openfire面板中找不到
sala3
房间。 我发送的
数据包有什么问题吗


谢谢。

它仍然很难看,但它起作用了

我把它添加到
XMPP.php

public function createGroup() {

        $out = "<presence from='24527@localhost/xmpphp' to='sala4@myconference.localhost/xmpphp'><x xmlns='http://jabber.org/protocol/muc'/></presence>";
        $this->send($out);
    }

    public function createGroup2() {

        $out = "<iq from='24527@localhost/desktop'
                    id='create1'
                    to='sala4@myconference.localhost/xmpphp'
                    type='get'>
                  <query xmlns='http://jabber.org/protocol/muc#owner'/>
                </iq>";

        $this->send($out);
    }

    public function sendConfigRoom() {

        $out = "<iq from='24527@localhost/desktop'
                id='create2'
                to='sala4@myconference.localhost/xmpphp'
                type='set'>
              <query xmlns='http://jabber.org/protocol/muc#owner'>
                <x xmlns='jabber:x:data' type='submit'>
                  <field var='FORM_TYPE'>
                    <value>http://jabber.org/protocol/muc#roomconfig</value>
                  </field>
                  <field var='muc#roomconfig_roomname'>
                    <value>A Dark Cave</value>
                  </field>
                  <field var='muc#roomconfig_roomdesc'>
                    <value>The place for all good witches!</value>
                  </field>
                  <field var='muc#roomconfig_enablelogging'>
                    <value>0</value>
                  </field>
                  <field var='muc#roomconfig_changesubject'>
                    <value>1</value>
                  </field>
                  <field var='muc#roomconfig_allowinvites'>
                    <value>0</value>
                  </field>
                  <field var='muc#roomconfig_allowpm'>
                    <value>anyone</value>
                  </field>
                  <field var='muc#roomconfig_maxusers'>
                    <value>10</value>
                  </field>
                  <field var='muc#roomconfig_publicroom'>
                    <value>0</value>
                  </field>
                  <field var='muc#roomconfig_persistentroom'>
                    <value>1</value>
                  </field>
                  <field var='muc#roomconfig_moderatedroom'>
                    <value>0</value>
                  </field>
                  <field var='muc#roomconfig_membersonly'>
                    <value>0</value>
                  </field>
                  <field var='muc#roomconfig_passwordprotectedroom'>
                    <value>1</value>
                  </field>
                  <field var='muc#roomconfig_roomsecret'>
                    <value>cauldronburn</value>
                  </field>
                  <field var='muc#roomconfig_whois'>
                    <value>moderators</value>
                  </field>
                  <field var='muc#maxhistoryfetch'>
                    <value>50</value>
                  </field>
                  <field var='muc#roomconfig_roomadmins'>

                    <value>24527@localhost</value>
                  </field>
                </x>
              </query>
            </iq> ";

        $this->send($out);
    }
<?php

// activate full error reporting
//error_reporting(E_ALL & E_STRICT);
error_reporting(E_ALL);
ini_set('display_errors', 'On');
include 'XMPPHP/XMPP.php';
    // load the image from filesystem

#Use XMPPHP_Log::LEVEL_VERBOSE to get more logging for error reports
#If this doesn't work, are you running 64-bit PHP with < 5.2.6?
    $conn = new XMPPHP_XMPP('myserver', 5222, '24527', 'my pw', 'xmpphp', 'localhost', $printlog=true, $loglevel=XMPPHP_Log::LEVEL_VERBOSE);

    $conn->connect();
    $conn->processUntil('session_start');
    $conn->useEncryption(false);
    $conn->createGroup();
    $conn->processUntil('presence');

    $conn->createGroup2();
    $conn->processUntil('result');

    $conn->sendConfigsRoom();

    #$conn->processUntil(array('result', 'error'));
    $conn->disconnect();