clankipad Posted September 9, 2015 Share Posted September 9, 2015 Bonjour à tous, Je développe actuellement un web service pour une application mobile. Je suis capable de connecter un utilisateur, créer des comptes utilisateurs, créer des paniers mais je n'arrive pas à créer des commandes. J'ai l'erreur suivante : HTTP XML response is not parsable: array ( 0 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 9, 'column' => 64, 'message' => 'Input is not proper UTF-8, indicate encoding ! Bytes: 0x95 0x08 0x77 0xE2 ', 'file' => '', 'line' => 778, )), 1 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 9, 'column' => 65, 'message' => 'PCDATA invalid Char value 8 ', 'file' => '', 'line' => 778, )), 2 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 9, 'column' => 77, 'message' => 'PCDATA invalid Char value 12 ', 'file' => '', 'line' => 778, )), 3 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 9, 'column' => 78, 'message' => 'PCDATA invalid Char value 14 ', 'file' => '', 'line' => 778, )), 4 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 64, 'column' => 51, 'message' => 'XML declaration allowed only at the start of the document ', 'file' => '', 'line' => 14954, )), 5 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 64, 'column' => 51, 'message' => 'XML declaration allowed only at the start of the document ', 'file' => '', 'line' => 17864, )), 6 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 64, 'column' => 51, 'message' => 'XML declaration allowed only at the start of the document ', 'file' => '', 'line' => 20773, )), 7 => LibXMLError::__set_state(array( 'level' => 3, 'code' => 64, 'column' => 33, 'message' => 'XML declaration allowed only at the start of the document ', 'file' => '', 'line' => 21368, )), ) J'ai essayé de changer l'encodage de la page en UTF-8 mais rien n'y fait. Voici mon code PHP : <?php // Here's how you create a webservice call: define('PS_SHOP_PATH', 'localhost:8888/MON_SITE'); define('PS_WS_AUTH_KEY', 'MA_CLEF'); define('DEBUG', true); require_once('PSWebServiceLibrary.php'); try { $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG); $opt = array('resource' => 'orders'); $xml = $webService->get(array('url' => PS_SHOP_PATH.'/api/orders?schema=synopsis')); $xml->children()->children()->id_address_delivery = 6; $xml->children()->children()->id_address_invoice = 6; $xml->children()->children()->id_cart = 136; $xml->children()->children()->id_currency = 1; $xml->children()->children()->current_state = 1; $xml->children()->children()->id_lang = 1; $xml->children()->children()->id_customer = 1; $xml->children()->children()->id_carrier = 0; $xml->children()->children()->total_paid = '56973'; $xml->children()->children()->total_paid_real = '56973'; $xml->children()->children()->total_paid_tax_excl = '56973'; $xml->children()->children()->total_paid_tax_incl = '56977'; $xml->children()->children()->total_products = 1338; $xml->children()->children()->total_products_wt = 1337; $xml->children()->children()->conversion_rate = '1'; $xml->children()->children()->secure_key = md5('-1'); $xml->children()->children()->valid = 1; $xml->children()->children()->module = 'Cheque'; $xml->children()->children()->payment = 'cheque'; $xml->children()->children()->current_state = 1; unset($xml->children()->children()->id); unset($xml->children()->children()->date_add); unset($xml->children()->children()->date_upd); unset($xml->children()->children()->associations); unset($xml->children()->children()->delivery_date); unset($xml->children()->children()->invoice_date); unset($xml->children()->children()->total_discounts_tax_incl); unset($xml->children()->children()->total_discounts_tax_excl); $xml = $webService->add(array('resource' => 'orders', 'postXml' => $xml->asXML() )); $resources = $xml->children()->children(); echo "Successfully added order.".$resources->id; } catch (PrestaShopWebserviceException $ex) { // Here we are dealing with errors $trace = $ex->getTrace(); if ($trace[0]['args'][0] == 404) echo 'Bad ID'; else if ($trace[0]['args'][0] == 401) echo 'Bad auth key'; else echo 'Other error<br />'.$ex->getMessage(); } ?> En espérant que certains sauront me venir en aide... Merci ! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now