Welcome Guest, Not a member yet? Register   Sign In
post xml to server
#1

[eluser]Unknown[/eluser]
I need to send the following xml to a remote server
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Query>
<Options MaxResults="50" />
<AvailableProducts QueryId=”MyGenericQuery”>
<Include>
<Descriptions />
<Media>productpic</Media>
</Include>
<Constraints>
<ProductType>available</ProductType>
</Constraints>
</AvailableProducts>
</Query>

I tried using curl first but I had no luck...now I'm trying with xml-rpc but I am not sure what name I should put for the method.

The only other info I have is the url where I need to post everything

http://www.example.com/example/example.xml


Can I achieve anything using XML-RPC or should I keep on trying with curl?
#2

[eluser]WillKemp[/eluser]
You haven't given much information really - but perhaps you haven't got much information yourself. Presumably you need to send it using the POST method.

You should be able to make it work with curl. I struggled with something similar a while ago - with no information other than the format of the xml required. Curl worked ok once i'd sussed out how to make it do it. I'd stick with curl if i was you.

What have you tried so far?
#3

[eluser]Unknown[/eluser]
Hey,
Thanks for your help...
I've made it work eventually but will keep digging into xml-rpc.
I just love CI Smile

here's the code for anyone in need

Code:
$server  = 'URLGOESHERE'; // URL to server.php
        $headers=array("Content-Type: text/xml");
    
        $post ='XMLGOESHERE';

        $options = array
        (
            CURLOPT_POST           => true,
            CURLOPT_URL            => $server,
            CURLOPT_HTTPHEADER     => $headers,
            CURLOPT_POSTFIELDS     => $post,
            CURLOPT_RETURNTRANSFER => true
        );

        $curl = curl_init();
        curl_setopt_array($curl, $options);
        $response = curl_exec($curl);
        curl_close($curl);




Theme © iAndrew 2016 - Forum software by © MyBB