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

131 lines
5.1 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.
// Paramètres de tests :
// • Enseigne : BDTEST13
// • Clé Privée : PrivateK
// Recupérer les identifiants
$reqSelect="Select idCompte, pwdCompte from `modeliv` WHERE idModeLiv=8 ;";
if (isset($debug[2]) && $debug[2] == '1' ) $debugMsg .=monDebug(2,['reqSelect' => $reqSelect],'WSI2_STAT_Label.php');
$resConn=$idPdo->query($reqSelect);
if ($resConn) {
$res=$resConn->fetch(PDO::FETCH_ASSOC);
$MR_WebSiteId=$res['idCompte'];
$MR_WebSiteKey=$res['pwdCompte'];
if (isset($debug[2]) && $debug[2] == '1' ) {echo '<br> secret= ' .$secret;}
}
require_once ('nusoap-0.9.6/lib/nusoap.php');
// $ = $compte;
// $ = $secret;
$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,
'STAT' => $MR_WebSiteId,
'Langue' => "Fr",
);
// 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_STAT_Labels',
$params,
'https://api.mondialrelay.com/',
'https://api.mondialrelay.com/WSI2_STAT_Labels'
);
// 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>'; }
}
// pour debug
echo '<pre>'.print_r($result). '</pre>';
// echo '_SESSION[idPointRelais]=' .$_SESSION['idPointRelais'];
$PRelais=$result;
$myVar="";
// flag traduction EDT
// $myVar='<span class="msgPanier" style="text-decoration:underline">Liste des points relais</span>';
$a=0;
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";
$trouve=false;
$myVar .= '<span style="padding:left:0;" >';
if ($key2!==0 && $value2!=='') {
if (strpos( $key2, "LgAdr1")!==false) {
$myVar .= "<span class=\"libPanier\" style=\"padding:left:0;\">&bull; $value2 </span>\n<br />";
$trouve=true;
}
if ($value2=='FR') $value2='FRANCE';
// Pas besoin de libellés de champs
if (strpos( $key2, "LgAdr3")!==false || strpos( $key2, "LgAdr2")!==false || strpos( $key2, "LgAdr4")!==false|| strpos( $key2, "Pays")!==false) {
$myVar .= '<span class="champsPanier" style="padding:left:0;font-size:0.9em;" >';
$myVar .= "" .$value2. "\n<br />";
$myVar .= '</span>';
$trouve=true;
}
// CP pas de <br> : collé avec ville
if (strpos( $key2, "CP")!==false) {
$myVar .= '<span class="champsPanier" style="padding:left:0;font-size:0.9em;" >';
$myVar .= "" .$value2;
$myVar .= '</span>';
$trouve=true;
}
// Espace avant pour ville
if (strpos( $key2, "Ville")!==false) {
$myVar .= '<span class="champsPanier" style="padding:left:0;font-size:0.9em;" >';
$myVar .= " " .$value2. "\n<br />";
$myVar .= '</span>';
$trouve=true;
}
// Si horraire on affichera en 7
if (strpos( $key2, "Horaires")!==false) {
$myVar .= " ";
$trouve=true;
}
// affiche les autres champs
if ($trouve==false) {
// $myVar .= "$key2 : $value2 \n<br />";
}
// $aff=1;
}
$trouve=false;
$aff=0;
$myVar .= '</span>';
}
}
echo '' .$myVar. '';
// echo '<div style="max-width:80%"><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>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>';
?>