0

它只返回“success1”。这是我的代码和 xml 文件。请任何人帮助我为什么不将产品导入 volusion。当我运行此代码时,它只返回 1。我不知道问题出在哪里,并且没有插入产品。

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

  1. 我的 Api 请求代码

//  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://tebkq.mvlce.servertrust.com/net/WebService.aspxLogin=mylogin&EncryptedPassword=mypassword&Import=Insert";

//  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);
     //echo $data;
    //  Check for Errors
    if (curl_errno($ch)){
        echo "error";
        print curl_error($ch);
    } else {
        echo "success";
       curl_close($ch);
    }

   //  Display the Xml Returned on the Browser
    echo $data;
?>
4

2 回答 2

0

在您的 xml 中,尝试用 xmldata 替换导入节点:

<?xml version="1.0" encoding="utf-8" ?>
<xmldata>
    <Products>
        <ProductID>360</ProductID>
        .....
    </Products>
</xmldata>

这是我在发送插入或更新时用于标题的内容

curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:application/x-www-form-urlencoded; charset=utf-8", "Content-Action:Volusion_API"));
于 2016-10-26T12:39:20.620 回答
0

删除<Import></Import>它应该可以工作。

于 2016-10-24T16:43:32.343 回答