alpha_full/pages/panier/mondialRelay/autresAPI/WSI2_TracingColisDetaille.php
2026-04-06 22:58:51 +02:00

153 lines
7.0 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
$nomFicAppelant = basename(__FILE__);
// https://api.mondialrelay.com/Web_Services.asmx?op=WSI2_TracingColisDetaille
// Cet exemple de code effectue une recherche des Points Relais® en 24R dans un rayon de 20Km
// autour du code postal 75010 en France dont la nature dactivité peut être définie.
require_once ('nusoap-0.9.6/lib/nusoap.php');
$MR_WebSiteId = "CC225B3G";
$MR_WebSiteKey = "NwO07OSQ";
$client = new nusoap_client("http://api.mondialrelay.com/Web_Services.asmx?WSDL", true);
$client->soap_defencoding = 'utf-8';
// param SOAP
$params = array(
'Enseigne' => $MR_WebSiteId,
'Expedition'=>"",
'Langue'=>"",
);
// On génère la clé de sécurité de l'appel
$code = implode("", $params);
$code .= $MR_WebSiteKey;
$params["Security"] = strtoupper(md5($code));
// l'appel SOAP
$result = $client->call(
'WSI2_TracingColisDetaille',
$params,
'https://api.mondialrelay.com/',
'https://api.mondialrelay.com/WSI2_TracingColisDetaille'
);
// On vérifie qu'il n'y a pas eu d'erreur
if ($client->fault)
{
echo '<h2>Fault (Expect - The request contains an invalid SOAP body)</h2><pre>';
print_r($result);
echo '</pre>';
}else {
$err = $client->getError();
if ($err) {echo '<h2>Error</h2><pre>' . $err . '</pre>'; }
}
// print_r($result);
$PRelais=$result;
$myVar="";
// flag EDT
$myVar="Liste des points relais";
foreach($PRelais as $key => $value) {
// $myVar= "\n<br> 1 - $key => $value \n<br />\n";
// $myVar .= " \n<br />\n";
foreach( (array)$value as $key2 => $value2) {
// $myVar .= "2 - $key2 => $value2 \n<br />\n";
// $myVar .= " \n<br />\n";
foreach( (array)$value2 as $key3 => $value3) {
// if ($key3!=0) $myVar .= "3 - $key3 => $value3 \n<br />\n";
// $myVar .= " \n<br />\n";
foreach( (array)$value3 as $key4 => $value4) {
// $myVar .= "\n<br>4 - $key4 => $value4 \n<br />\n";
$myVar .= " \n<br /><div style='width:100%;border:1px solid blue;border-radius:3px;'>\n";
// $horraire=0;
foreach( (array)$value4 as $key5 => $value5) {
$trouve=false;
if ($key5!==0 && $value5!=='' && $key5!=='Num' && $key5!=='Distance' &&$key5!=='Localisation1' && $key5!=='Longitude' && $key5!=='Latitude') {
if (strpos( $key5, "LgAdr1")!==false) {
$myVar .= " Enseigne : $value5 \n<br />";
$trouve=true;
}
if ($value5=='FR') $value5='France';
// Pas besoin de libellés de champs
if (strpos( $key5, "LgAdr3")!==false || strpos( $key5, "LgAdr2")!==false || strpos( $key5, "LgAdr4")!==false|| strpos( $key5, "Pays")!==false) {
$myVar .= "" .$value5. "\n<br />";
$trouve=true;
}
// CP pas de <br> : collé avec ville
if (strpos( $key5, "CP")!==false) {
$myVar .= "" .$value5;
$trouve=true;
}
// Espace avant pour ville
if (strpos( $key5, "Ville")!==false) {
$myVar .= " " .$value5. "\n<br />";
$trouve=true;
}
// Si horraire on affichera en 7
if (strpos( $key5, "Horaires")!==false) {
$myVar .= " ";
$trouve=true;
}
if ($trouve==false) {
// $myVar .= "$key5 : $value5 \n<br />";
}
// $aff=1;
}
$trouve=false;
$aff=0;
foreach( (array)$value5 as $key6 => $value6) {
// if ($key6!==0 && $value6!==''&& $key6!=='string') {
// if (!(array)$value6)
// $myVar .= "$key6 : " .$value6. " ";
// // $horraire=$horraire+1;
// $trouve=false;
// }
$trouve=false;
foreach( (array)$value6 as $key7 => $value7) {
if ($value7!=='' && $key5!=='Distance' && $key5!=='Num' && $key5!=='Localisation1' && $key5!=='Longitude' && $key5!=='Latitude' && $key5!=='Pays' && $key5!=='Ville' && $key5!=='CP' && $key5!=='LgAdr1' && $key5!=='LgAdr2' && $key5!=='LgAdr3') {
$myVar .= '<span style="color:#353333;" >';
if (strpos( $key5, "Horaires") !==false && $trouve==false && $value7!=0 ) {
// on enleve le mot Horraire_
$myVar .= "".substr($key5,-(strlen($key5)-9)). " : ".substr($value7,0,2). "H".substr($value7,-2);
// on a trouvé au moins 1 horraire
$trouve=true;
$aff=1;
} else {
if ($value7!=0) $myVar .= " - ".substr($value7,0,2). "H".substr($value7,-2);
}
if (empty($value6) && strpos( $key5, "Horaires_Lundi") !==false) {
$myVar .= "" .$key5. " : Fermé ";
}
$myVar .= '</span" >';
}
}
if ($aff==1) $myVar .= "\n<br />\n";
}
}
$myVar .= "</div>";
}
}
}
}
echo '' .$myVar. '';
// echo '<div style="max-width:80%""><br><h2>Request</h2><span white-space: pre-wrap;word-wrap:break-word; word-break: break-all;>' . nl2br(htmlspecialchars($client->request, ENT_QUOTES)) . '</span>';
// echo '<br><h2>Request</h2><span style="white-space: pre-wrap;word-wrap:break-word; word-break: break-all;">' . nl2br(htmlspecialchars($client->request, ENT_QUOTES)) . '</span>';
// echo '<br><h2>Response</h2><span style="white-space: pre-wrap;word-wrap:break-word; word-break: break-all;"><pre>' . nl2br(htmlspecialchars($client->response, ENT_QUOTES)) . '</pre></span>';
// echo '<br><h2>Debug</h2><span style="white-space: pre-wrap;word-wrap:break-word; word-break: break-all;"><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre></span></div>';
?>