如何添加/导入/插入新产品到Volusion使用Volusion API在PHP与cURL


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

你能帮我了解如何在PHP中使用Volusion API添加新产品吗?

任何有用的链接将不胜感激。

  1. 创建一个名为"myXML.txt"的XML文件。

<Import>
   <Products>
      <ProductID>360</ProductID>
      <productcode>10035</productcode>
      <vendor_partno>035</vendor_partno>
      <productname>Asus Video Card ATI Doulat</productname>
      <listprice>6.95</listprice>
      <productprice>2</productprice>
      <vendor_price>3.83</vendor_price>
      <stockstatus>100</stockstatus>
      <upc_code>99999</upc_code>
      <categoryids>107,134</categoryids>
      <productdescriptionshort />
      <productdescription />
      <productweight>0.00</productweight>
      <freeshippingitem />
      <minqty />
      <maxqty />
   </Products>
</Import>

然后复制粘贴到你的编辑器

<?php
    $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 = "https://www.xxxxxusa.com/net/WebService.aspx?Login=xxxx@xxxxxxxcom.com&EncryptedPassword=0000000000000000000000000000xxxxxxxxxx&Import=Update";
//  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 {
       curl_close($ch);
    }
   //  Display the Xml Returned on the Browser
    echo $data;
?>

请记住,使用您自己的API凭据。试试这个,希望你能得到答案。