Debugger Debugger - 1 year ago 161
PHP Question

How to Add/Import/Insert new products to Volusion using Volusion API in PHP with cURL

Could you help me to understand how to add new products to Volusion using the Volusion API in PHP with something like cURL?

Any useful links will be appreciated.

Answer Source
  1. Make XML file in the format like this with name "myXML.txt".

      <productname>Asus Video Card ATI Doulat</productname>
      <productdescriptionshort />
      <productdescription />
      <freeshippingitem />
      <minqty />
      <maxqty />

  1. Then copy and paste this in your editor


    $file = file_get_contents('myXML.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 = "";

//  Create the Header   

    $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;

Remember this use your own API credential. Try this hope you got the answer.

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