Jabber搜索高级用户搜索

时间:2015-05-26 13:53:27

标签: xmpp strophe

我尝试在我的xmpp服务器中按用户名搜索用户,但结果始终不包含任何项目...

获取我发送的表单格式:

<iq type='get' to='search.MY_SERVER' xmlns='jabber:client'>
  <query xmlns='jabber:iq:search'/>
</iq>

并收到:

<iq xmlns="jabber:client" type="result" id="3:sendIQ" from="search.MY_SERVER" to="ID@MY_SERVER/7acf23bb">
  <query xmlns="jabber:iq:search">
  <instructions>The following fields are available for searching. Wildcard (*) characters are allowed as part of the query.</instructions>  
    <first/><last/><nick/><email/>
  <x xmlns="jabber:x:data" type="form">
    <title>Advanced User Search</title>
    <instructions>The following fields are available for searching. Wildcard (*) characters are allowed as part of the query.</instructions>
    <field var="FORM_TYPE" type="hidden">
      <value>jabber:iq:search</value>
    </field>
    <field var="search" type="text-single" label="Search">
      <required/>
    </field>
    <field var="Username" type="boolean" label="Username">
      <value>1</value>
    </field>
    <field var="Name" type="boolean" label="Name">
      <value>1</value>
    </field>
    <field var="Email" type="boolean" label="Email">
      <value>1</value>
    </field>
  </x>
  </query>
</iq>

然后我发送:

<iq type='set' to='search.MY_SERVER' xmlns='jabber:client'>
  <query xmlns='jabber:iq:search'>
  <x xmlns='jabber:x:data' type='submit'>
  <field type='hidden' var='FORM_TYPE'>
    <value>jabber:iq:search</value>
  </field>
  <field var='search'>
    <value>*</value>
  </field>
  </x>
  </query>
</iq>

但未收到任何物品:

<iq xmlns="jabber:client" type="result" id="4:sendIQ" from="search.MY_SERVER" to="ID@MY_SERVER/7acf23bb">
  <query xmlns="jabber:iq:search">
  <x xmlns="jabber:x:data" type="result">
  <field var="FORM_TYPE" type="hidden"/>
  <reported>
    <field var="jid" type="jid-single" label="JID"/>
    <field var="Username" type="text-single" label="Username"/>
    <field var="Name" type="text-single" label="Name"/>
    <field var="Email" type="text-single" label="Email"/>
  </reported>
  </x>
  </query>
</iq>

有人知道出了什么问题吗?

1 个答案:

答案 0 :(得分:0)

我找到了答案,发送以下请求就可以了:

<iq type='set' to='search.MY_SERVER' xmlns='jabber:client'>
  <query xmlns='jabber:iq:search'>
    <x xmlns='jabber:x:data' type='submit'>
      <field var='search'>
        <value>SEARCH_CRITERIA</value>
      </field>
      <field var='Username'>
        <value>1</value>
      </field>
    </x>
  </query>
</iq>