且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

XEP-0055错误400错误的请求?

更新时间:2022-01-28 07:34:48

此搜索服务不支持普通 XEP-0055搜索字段,但需要您提交 x:data 对获取请求的响应中返回的表格;参见 XEP-0004

This search service doesn't support "plain" XEP-0055 search fields, but requires you to submit the x:data form returned in the response to the "get" request; see XEP-0004.

您可以通过以下事实来说明这一点:结果不包含任何建议的搜索字段作为查询元素的子元素(请参阅XEP-0055的示例2),还包括< instructions />。 元素是这样的。这意味着您需要查看< x xmlns = jabber:x:data type = form> 元素并提交。

You can tell this by the fact that the result doesn't contain any suggested search fields as children of the query element (see example 2 of XEP-0055), and also the <instructions/> element says so. This means that you need to look at the <x xmlns="jabber:x:data" type="form"> element and submit it.

因此,您需要发送以下内容:

Thus, you need to send something like:

<iq type='set'
    from='juliet@capulet.com/balcony'
    to='characters.shakespeare.lit'
    id='search4'
    xml:lang='en'>
  <query xmlns='jabber:iq:search'>
    <x xmlns='jabber:x:data' type='submit'>
      <field var='user'>
        <value>admin</value>
      </field>
    </x>
  </query>
</iq>

(这是XEP-0055的示例8,已修改为搜索用户名为 admin的用户)

(This is example 8 from XEP-0055, modified to search for the user with username "admin".)