Prestashop Web服务(dom_import_simplexml错误)

时间:2015-07-22 08:45:04

标签: php xml prestashop

我正在通过windows bash

执行此代码
c:\xampp\php\php.exe c:\xampp\htdocs\pais.php 1 1 53 CU 1 0 0 1 NNNNN 1 1 Cuba

我正在调用php.exe传递我更新数据库所需的所有参数,但函数dom_import_simplexml每次都会返回错误。

这是我的pais.php代码:

<?php


require_once('PSWebServiceLibrary.php');
define('STORE_PATH','http://localhost/prestashop');
define('KEY','KN5NBZWT3QYLGZX86DV14ZX317BHVPTL');
define('DEBUG','true');

try {
    $webService = new PrestaShopWebservice(STORE_PATH,KEY,DEBUG);

    $xml = $webService->get(array('url' =>STORE_PATH.'/api/countries?schema=blank'));
    $resources = $xml->children()->children();


    unset($resources -> id_zone);
    unset($resources -> iso_code);
    unset($resources -> contains_states);
    unset($resources -> display_tax_label);
    unset($resources-> name);


    $resources-> id_zone = utf8_encode(strval($argv[1]));
    $resources-> id_currency = utf8_encode(strval($argv[2]));
    $resources-> call_prefix = (int)$argv[3];
    $resources-> iso_code = utf8_encode(strval($argv[4]));
    $resources-> active = utf8_encode(strval($argv[5]));
    $resources-> contains_states = utf8_encode(strval($argv[6]));
    $resources-> need_identification_number = utf8_encode(strval($argv[7]));
    $resources-> need_zip_code = utf8_encode(strval($argv[8]));
    $resources-> zip_code_format = utf8_encode(strval($argv[9]));
    $resources-> display_tax_label = utf8_encode(strval($argv[10]));

    $node = dom_import_simplexml($resources-> name -> language[0][0]);
    $no = $node -> ownerDocument;
    $node -> appendChild($no -> createCDATASection(utf8_encode(strval($argv[12]))));
    $resources -> name -> language[0][0] = utf8_encode(strval($argv[12]));
    //$resources -> name -> language[0][0]['id'] = utf8_encode(strval($argv[11]));
    //$resources -> name -> language[0][0]['xlink:href'] = STORE_PATH . '/api/languages/' . utf8_encode(strval($argv[11]));

    $opt = array('resource' => 'countries');
    $opt['postXml'] = $xml->asXML();
    $xml = $webService->add($opt);

}

catch (PrestaShopWebserviceException $ex) {
    // Shows a message related to the error
    echo 'Other error: <br />' . $ex->getMessage();
}

?>

这是有问题的错误:

Warning: dom_import_simplexml() expects parameter 1 to be object, null given in C:\xampp\htdocs\pais.php on line 37 Notice: Trying to get property of non-object in C:\xampp\htdocs\pais.php on line 38 Fatal error: Call to a member function appendChild() on null in C:\xampp\htdocs\pais.php on line 39

有人可以帮助我吗?

0 个答案:

没有答案