Jump to content

webservice aggiungere nuovo customer da errore


iJim

Recommended Posts

Salve a tutti.

Ho creato un file php per aggiungere un nuovo customer tramite richiesta POST, ma ho quest errore:

 

<error>
<code><![CDATA[127]]></code>
<message><![CDATA[XML error : String could not be parsed as XML

Questo è il mio codice sorgente:

 

    try {
        define('PS_SHOP_PATH',         '***');
        define('PS_WS_AUTH_KEY',     '***');
        define('PS_WS_DEBUG',         true);
        
        require_once( './PSWebServiceLibrary.php' );
        $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, PS_WS_DEBUG);

        $opt = array();
        $opt['url'] = PS_SHOP_PATH . '/api/customers?schema=synopsis';
        $opt['resource'] = 'customers';
        $xml = $webService->get($opt);
        $resources = $xml->children()->children();

        foreach ($resources as $key => $resource){
            $resources->$key = $_POST[$key];
        }

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

        echo '-- OK --';
        }

        catch (PrestaShopWebserviceException $ex) {
             ...
        }
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...