美好的一天,我有一个问题
我使用webservice在prestashop中添加产品,我现在已经解决了所有其他问题,但这让我感到恶心。
首先,我使用cdata节点几乎所有的东西,它很顺利,但是当它出现时,我有这个代码:
$xml = $webService -> get(array('url' => PS_SHOP_PATH . '/api/products?schema=blank'));
$resources = $xml -> children() -> children();$no = $node -> ownerDocument;
....
....
$node -> appendChild($no -> createCDATASection($n_desc));
$resources -> description -> language[0][0] = $n_desc;
$resources -> description -> language[0][0]['id'] = $n_l_id;
$resources -> description -> language[0][0]['xlink:href'] = PS_SHOP_PATH . '/api/languages/' . $n_l_id;
....
....
try {
//print_r($xml);
$opt = array('resource' => 'products');
$opt['postXml'] = $xml -> asXML();
$xml = $webService -> add($opt);
return true;
} catch (PrestaShopWebserviceException $ex) {
//echo '<b>Error : '.$ex->getMessage().'</b>';
//$trace = $ex->getTrace();
//print_r($trace);
return false;
}
描述来自:
$n_desc = $row['descrizione'];
这是回复:
HTTP/1.1 500 Internal Server Error
Date: Wed, 26 Feb 2014 15:37:59 GMT
Server: Apache/2.2.16 (Debian)
Vary: Host,Accept-Encoding
X-Powered-By: PrestaShop Webservice
Access-Time: 1393429079
PSWS-Version: 1.5.6.1
Execution-Time: 0.026
然后它发送了所有xml,描述部分是:
<description><language id="1" xlink:href="server.com/api/languages/1"><p><span style="font-size: 16px,">lorem ipsum dolor sit ...
我试着对它进行编码,real_escape,utf_encode,url encode ......没有。
修改 当然,如果我发送一个描述字符串,如“描述”,一切都很顺利。
有没有人有想法?提前谢谢。