Jump to content

Problème Creation Customer Via Web Service


atwebmaster

Recommended Posts

Bonsoir tout le monde ,

j’essaie de créer un nouveau client depuis un web service mais ca passe pas (erreur serveur 500).

voici mon code test2.php

<?php
define('DEBUG', true);
define('PS_SHOP_PATH', 'http://monsite.com/');
define('PS_WS_AUTH_KEY', 'W1S3X9IAX4589DERFNNN5VQPYD2DGA8L');
require_once('PSWebServiceLibrary.php');
// Getting the empty XML document to send back completed
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$xml = $webService->get(array( 'url' => PS_SHOP_PATH.'/api/customers?schema=blank'));
$resources = $xml->children()->children();
 
// Information about the customer to create
$infos = array(
    'id' => '444',
    'passwd' => 'test123',
    'lastname' => 'test',
    'firstname' => 'lol',
    'email' => '[email protected]',
);
 
// Completing the XML document
foreach ( $resources as $nodeKey => $node ) {
  $resources->$nodeKey = $infos[$nodeKey];
}
 

try 
{
   // Send !
$opt = array( 'resource' => 'customers' );
$opt['postXml'] = $xml->asXML();
print_r($opt);
$xml = $webService->add($opt);

} 
catch (PrestaShopWebserviceException $e) 
{
    echo 'Something went wrong: '.$e->getMessage();
}

?>

les ficher test2.php et PSWebServiceLibrary.php sont sur le maim dossier .

 

Merci .

Edited by atwebmaster (see edit history)
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...