close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Submit Form post as XML

Thread began 10/30/2012 7:45 pm by Jaffa | Last modified 10/31/2012 8:50 pm by Jaffa | 2045 views | 3 replies


Submit Form post as XML


I'm trying to create a new shipping calculator for my Ecart store using InterParcel here in Australia. I have the API guide and have built the following code in accordance to their guide, however I don't get a response back from the server. Curl is Enabled on the host server and i receive the correct lines if i echo the results but no server response? Do i need to put the $post_string into an array. Example of the bad request is here:xml-form.php Use Suburb Sydney Postcode:2000

Any ideas?

My code looks like this

// Your post data
$post_city= $_POST['city'];
$post_postcode = $_POST['postcode'];

// Building your XML string
$strXML = '<?xml version="1.0" encoding="UTF-8"?>'."\n";
$strXML .= '<Request>'."\n";
$strXML .= '<Authentication>'."\n";
$strXML .= '<UserID></UserID>'."\n";
$strXML .= '<Password>pass123456</Password>'."\n";
$strXML .= '<Version>1.0</Version>'."\n";
$strXML .= '</Authentication>'."\n";

$strXML .= '<RequestType>Rates</RequestType>'."\n";
$strXML .= '<ShowAvailability>N</ShowAvailability>'."\n";

$strXML .= '<Shipment>'."\n";

$strXML .= '<Collection>'."\n";

$strXML .= '<City>Cranbourne</City>'."\n";
$strXML .= '<Country>Australia</Country>'."\n";
$strXML .= '<Postcode>3977</Postcode>'."\n";
$strXML .= '</Collection>'."\n";

$strXML .= '<Delivery>'."\n";
$strXML .= '<City>'.$post_city.'</City>'."\n";
$strXML .= '<Country>Australia</Country>'."\n";
$strXML .= '<Postcode>'.$post_postcode.'</Postcode>'."\n";
$strXML .= '</Delivery>'."\n";

$strXML .= '<Package>'."\n";
$strXML .= '<Weight>4</Weight>'."\n";
$strXML .= '<Length>43</Length>'."\n";
$strXML .= '<Width>46</Width>'."\n";
$strXML .= '<Height>66</Height>'."\n";
$strXML .= '</Package>'."\n";

$strXML .= '</Shipment>'."\n";
$strXML .= '</Request>'."\n";

$url = "";

$post_string = $strXML;

$header = "POST HTTP/1.0 \r\n";
$header .= "Content-type: text/xml \r\n";
$header .= "Content-length: ".strlen($post_string)." \r\n";
$header .= "Content-transfer-encoding: text \r\n";
$header .= "Connection: close \r\n\r\n";
$header .= $post_string;

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);

$data = curl_exec($ch);

print curl_error($ch);


Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...