1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
| <?php
$info_json_decode = json_decode($recupere_json;
$n_commande = $info_json_decode->n_commande;
$price_usd = $info_json_decode->price_usd;
foreach ($info_json_decode->lignes_commande as $obj_montre)
{
switch($obj_montre->types_produit)
{
case 'montres' :
$email = $info_json_decode->email;
$last_name = $info_json_decode->address->last_name;
$phone = $info_json_decode->address->phone;
$chercheProduitId = cherche(array("-","--","---"),$obj_montres->id_numb);
$produitId = $chercheProduitId[0];
$commandeXml = '<?xml version="1.0" encoding="utf-8"?>';
$commandeXml .= '<order><transactionId>' ;
$commandeXml .= $n_commande;
$commandeXml .= '</transactionId>';
$commandeXml .= '</order>';
$lien_ws = $lien_ws . $produitId. '?clntId=' . $clntId . '&keyN=' . $keyN ;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $lien_ws);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array('xml' => $commandeXml)));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // recevoir le résultat du transfert
$responseRecu = curl_exec($curl);
if(curl_errno($curl))
{
// erreur CURL c'est ici
$fichier_log = "\r\n" .'CURL\'S Error number: "' . curl_errno($curl) . '" and Error info: "'. curl_error($curl). '"'."\r\n";
file_put_contents($repertoire, $fichier_log, FILE_APPEND | LOCK_EX);
}
else
{
// pas d'erreur CURL c'est ici REUSSI
file_put_contents($repertoire, $data_for_log, FILE_APPEND | LOCK_EX);
// ligne 56 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
libxml_use_internal_errors(true);
$dom_OffLine = new DOMDocument;
$dom_OffLine->loadHTML($responseOffLine);
$nodeListToFind = $dom_OffLine->getElementsByTagName('senttooffline'); // <sentToOffline>false</sentToOffline>
if ($nodeListToFind->length)
{
$responseOffLine_contains_false = $nodeListToFind->item(0)->nodeValue;
if ($responseOffLine_contains_false == 'true')
{
echo '<p> true donc les informations sont reçu même s\'il y a un timeOut alors il ne faut plus envoyer une autre fois</p>';
$nodeListMessage = $dom_OffLine->getElementsByTagName('message');
$raison_error = $nodeListMessage->item(0)->nodeValue;
echo '<p> pas de raison' . $raison_error . '</p>';
curl_close($curl); // ligne 77 !!!! ligne 77 !!!! ligne 77 !!!! ligne 77 !!!!
}
else
{
echo "<p>sent To Offline ::: F A L S E </p>";
$nodeListMessage = $dom_OffLine->getElementsByTagName('message');
$raison_error = $nodeListMessage->item(0)->nodeValue;
echo '<p> il faut empêcher d\'envoyer une deuxième fois parce que : '. $raison_error . '</p>';
}
}
}
curl_close($curl);
break; // FIN TRAITEMENT SUR LES MONTRES */
default:
// S'IL Y A D'AUTRES CHOSES QUE LE MONTRE,
//ON NE FAIT RIEN
break;
}
// FIN PAS DE MONTRE DANS types_produit */
}
// FIN foreache Construction les articles de montres ------------------------------------------------------------------------------------- */
exit(); |
Partager