XMPP For The Web/Win ::: XMPP-FTW (1.16.8)

XEP-0055 Jabber Search

Get search form

To retrieve the search form from the required source the following method is used:

        socket.send(
            'xmpp.search.get',
            {
                "to": "evilprofessor.co.uk"
            },
            function(error, data) { console.log(error, data) }
        )
        

The server may us a 'basic' or 'extensible' type search form and the two different formats are important for making the search query itself.

If the server uses a simple search form then the result will be returned in the following format:

        {
          instructions: "Please use the following search fields",
          basic: [ "first", "last", "jid", "nick" ]
        }
        

Should the server make use of extensibility then the result will appear in the following format:

        {
          instructions: "Please use the following search fields",
          form: ... data form ...
        }
        

Where form will be parsed according to data forms.

Performing a search

        socket.send(
            'xmpp.search.do',
            {
                "to": "evilprofessor.co.uk",
             /* "basic": {
                  "nick": "lloydwatkin",
                  "first": "lloyd"
                }, */
             /* "form": [
                  { "var": "nick"', "value": "lloydwatkin" },
                  { "var": "first", "value": "lloyd" }
                ] */
            },
            function(error, data) { console.log(error, data) }
        )
        

Where the `form` is formatted as outlined in data forms.

Whether you provide a basic or form key very much depends on whether the chosen server is implementing basic or extensible search forms as mentioned above. When sending your payload ensure that the appropriate type is sent.

Note: If you provide both the basic and form parameters then preference will be given to basic.

Results

Results are returned in the following format:

        {
             fields: {
                 first: { label: "Given Name", var: "text-single" },
                 last: { label: "Family Name", var: "text-single" },
                 jid: { label: "JID", var: "jid-single" }
             },
             results: [
                 {
                     first: "Lloyd",
                     last: "Watkin",
                     jid: "[email protected]"
                 }
             ]
        }
        

Result values will be provided in arrays if the data type is of *-multi or otherwise appropriate. Empty results simply include an empty fields and empty results objects.

Pages

Fork me on GitHub