【问题标题】:How to send extra parameters in jaxl xmpp ejabberd?如何在 jaxl xmpp ejabberd 中发送额外参数?
【发布时间】:2018-08-01 04:40:55
【问题描述】:

我想向 xmpp 服务器发送一些额外的参数。但没有在 msg.xml 中获取那些额外的参数。 使用 https://github.com/jaxl/JAXL , https://www.ejabberd.im/

我正在尝试使用 jaxl.php 中的这种方法。

public function send_msg($to,$body,$sender_id,$id,$xmpp_msg_attribute,$thread=null, $subject=null) {
    $msg = new XMPPMsg(
        array(
            'id'=>$id,
            'sender_id'=>$sender_id,
            'type'=>'normal', 
            'to'=>$to, 
            'from'=>$this->full_jid->to_string(),
            'attributes'=> 'extra information',
        ), 
        $body,
        $thread,
        $subject
    );
    $this->send($msg);
}

但是不带额外参数的输出发送:

<message xml:lang='en'
         to='7070707070@localhost.com'
         from='9696969696@localhost.com/jaxl#3090b93066351b9a90ebad79bb208745'
         id='5b6137010b0bc'
         xmlns='jabber:client'>
  <body><p>check me</p></body>
</message>

我没有找到 attributes , sender_id 。 我还尝试更改属性-> attrs。

来源 http://jaxl.readthedocs.io/en/latest/users/xml_objects.html#xmppstanza

【问题讨论】:

    标签: php xmpp ejabberd jaxl


    【解决方案1】:

    Message 和 Body 元素已由 XMPP 协议定义,因此您无法向它们添加属性。

    但是你可以添加新元素,例如客户端可以发送这个,并且会被目的地接收:

    <message id='46:941386'
        xml:lang='es'
        type='chat'
        to='user2@localhost'>
      <body>hola</body>
      <xxx aa='asd' bb='qwe'/>
    </message>
    

    【讨论】:

    • 你是怎么做到的? ,我知道 $msg->c('message_extra'); $msg->t($xmpp_msg_attribute);但是属性 aa 和 bb 怎么样?举个例子
    • 我不使用 JAXL,所以我不知道如何在那个库中做到这一点。
    猜你喜欢
    • 2014-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多