【发布时间】:2017-03-16 20:22:08
【问题描述】:
实际上,我正在尝试使用 PHP cURL 方法通过 Volusion API 将产品导入我的 volusion 商店,产品已成功插入和更新,但类别和图像存在问题。不插入图像和类别。
当我打开我的管理员时,没有分配类别和图像。直到我手动分配然后它显示在前端。
谁知道请帮帮我。我的代码如下..
- 我的 XML 文件..
<?xml version="1.0" encoding="utf-8"?>
<product>
<productcode>960BX2SSD1</productcode>
<upc_code>649528774156</upc_code>
<productmanufacturer>Crucial</productmanufacturer>
<category>SATA3</category>
<categorytree></categorytree>
<productprice>259</productprice>
<stockstatus>Y</stockstatus>
<productweight>0.25</productweight>
<length>0</length>
<width>0</width>
<height>0</height>
<photo_alttext>960BX2SSD1.JPG</photo_alttext>
<photourl>http://www.malabs.com/i/960BX2SSD1.JPG</photourl>
<productdescription><p><b>SpecificationS</b></p><ul><li><strong>Mfr Part Number:</strong> CT960BX200SSD1</li><li><strong>Capacity:</strong> 960 GB</li><li><strong>Form Factor:</strong>;</productdescription>
</product>
- 我的 PHP 脚本
<?php
$file = file_get_contents('dataPro.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://xxxxxxxxxxxxx/net/WebService.aspx?Login=xxxxxxxxxxxxx&EncryptedPassword=xxxxxxxxxxx&Import=Insert-Update";
// Create the Header
// 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, array("Content-Type:application/x-www-form-urlencoded; charset=utf-8", "Content-Action:Volusion_API"));
$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;
?>
图片和类别丢失的错误在哪里。
【问题讨论】: