Brianne Riggle Brianne Riggle - 1 month ago 13
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 = "http://.servertrust.com/net/WebService.aspx?Login=support@mysite.com&EncryptedPassword=1234&Import=Insert";

$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 {
curl_close($ch);
}

// 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:

<ReturnResult>
<Success>False</Success>
<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

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).

Comments