* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 1.4 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include( '../../config/config.inc.php' );
function genAuth($username, $password)
{
return sprintf('
%s
%s
', htmlspecialchars($username), htmlspecialchars($password));
}
function getDepot($soapclient, $code)
{
$services = $soapclient->tntDepots(array('department' => $code));
return ($services);
}
if (!Configuration::get('TNT_CARRIER_LOGIN') || !Configuration::get('TNT_CARRIER_PASSWORD') || !Configuration::get('TNT_CARRIER_NUMBER_ACCOUNT'))
echo 'No account found';
else
{
$code = $_GET['code'];
$authheader = genAuth(Configuration::get('TNT_CARRIER_LOGIN'), Configuration::get('TNT_CARRIER_PASSWORD'));
$authvars = new SoapVar($authheader, XSD_ANYXML);
$header = new SoapHeader("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security", $authvars);
$file = "http://www.tnt.fr/service/?wsdl";
try {
$soapclient = new SoapClient($file, array('trace'=>1));
$soapclient->__setSOAPHeaders(array($header));
$follow = getDepot($soapclient, $code);
}
catch( SoapFault $e ) {
$erreur = $e->faultstring;
echo $erreur;
}
catch( Exception $e ) {
$erreur = "Problem : follow failed";
}
if (isset($follow))
{
//var_dump($follow);
if (isset($follow->DepotInfo))
{
$v = $follow->DepotInfo;
if (!is_array($follow->DepotInfo))
echo "
";
else
echo "
";
echo "
";
}
else
echo "Aucun dépôt trouvé";
}
}
?>