Using XML-RPC requests in external php

First of, I’m really new to this thing I am supposed to do, so my question might be basic or even phrased wrong, but I’m hoping someone will be able to help me out.

I have a website with a search form that I am supposed to “connect” to the search engine hosted elsewhere. Using the firefox restclient addon I can get the results I need by typing in xml requests via post method, also in xml form.

Read More

Now, I need to somehow make it that when the user types in a search query in my website, it sends a xml request to the search website, and takes the returned xml result and formats it into search results.

My website is built on wordpress, I am using a template that I built from scratch.

This way of doing this is not really my choice and I can’t really go about it in a different way. Right now I am even unsure where to begin, so all help is appreciated.

The method I will send requests to:

<?xml version="1.0"?>
<methodResponse>
<params>
    <param>
        <value>
            <array>
                <data>
                    <value>
                        <string>array</string>
                    </value>
                    <value>
                        <string>string</string>
                    </value>
                    <value>
                        <string>int</string>
                    </value>
                    <value>
                        <string>boolean</string>
                    </value>
                </data>
            </array>
        </value>
    </param>
</params>

In the search form (basic bootstrap search that currently has no functionality) the user will write down some search keywords which is the “string” parameter in the method above, the rest will be default (always the same). So I need to send that string and other vars, and the method will return search results which I will need to retrieve back to my site and publish them as search results.

Basically I need to send something like this:

<?xml version="1.0"?>
<methodCall>
  <methodName>index.search</methodName>
  <params>
    <param>
<value>
   <string>a</string>
</value>
</param>
    <param>
  <value>
  <int>10</int>
  </value>
</param>
    <param>
 <value>
  <boolean>0</boolean>
  </value>
  </param>  
   </params>
  </methodCall>

And I should recieve something like this:

  <?xml version="1.0"?>
     <methodResponse>
<params>
    <param>
        <value>
            <array>
                <data>
                    <value>
                        <struct>
                            <member>
                                <name>article_file_paragraph_id</name>
                                <value>
                                    <string>27003</string>
                                </value>
                            </member>
                            <member>
                                <name>article_file_id</name>
                                <value>
                                    <string>2186</string>
                                </value>
                            </member>
                            <member>
                                <name>article_id</name>
                                <value>
                                    <string>2152</string>
                                </value>
                            </member>
                            <member>
                                <name>paragraph</name>

(the result is way longer but I cut it)

Related posts

Leave a Reply