Brianne Riggle Brianne Riggle - 1 year ago 110
PHP Question

Product Import/Insertion using Volusion API

I am trying to Import/insert my products to my product table in volusion through the Volusion API I have used the sample PHP code provided by Volusion.

$file = file_get_contents('C:\Users\Ray\Desktop\3.txt', true);

// Create the Xml to POST to the Webservice

$Xml_to_Send = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
$Xml_to_Send .= "<Volusion_API>";
// $Xml_to_Send .= "<!--";
$Xml_to_Send .= $file;
// $Xml_to_Send .= "\"\"";
// $Xml_to_Send .= "-->";
$Xml_to_Send .= "</Volusion_API>";

$url = "";

$header = array(
"MIME-Version: 1.0",
"Content-type: text/xml; charset=utf-8",
"Content-transfer-encoding: text",
"Request-number: 1",
"Document-type: Request",
"Interface-Version: Test 1.4"

// Post and Return Xml
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $Xml_to_Send);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$data = curl_exec($ch);

// Check for Errors
if (curl_errno($ch)) {
print curl_error($ch);
} else {

// Display the Xml Returned on the Browser
echo $data;

This code works great as long as my xml file is under 10MB wich is the limit for the regular import. When I try to import anything over I receive this error:

<Message>Maximum request length exceeded.</message>
</ReturnResults>Send Failure: Connection was reset

Is there anyway to get around this limit? Like I stated the code works great until I hit the 10MB limit when I receive this error. The current file I am trying to import is only 30MB. Any script or solution that increase the size of file???

Answer Source

You're going to have to break up the file. I find that I can't import more than 10 or so products at a time without running into curl timeout errors (error code 28).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download