extranet/includes/giant/client.php
2010-10-21 13:10:04 +00:00

84 lines
3.1 KiB
PHP

<?php
// --------------------------------------------------------------------------- //
// envoieCourriel
// --------------------------------------------------------------------------- //
function envoieCourriel($sujet, $texte)
{
require_once 'mail/mail.php';
sendMail("[Giant] ".$sujet , $texte,
// From
array('email' => CONF_MEL_FROM,
'name' => 'Client Giant'),
// To
array(0 => array('email' => CONF_MEL_TO,
'name' => 'Support')));
}
// --------------------------------------------------------------------------- //
// getProviderId
// --------------------------------------------------------------------------- //
function getProviderId($pays)
{
switch ($pays) {
case 'BE': return '001';
case 'NL': return '003';
default:
print 'Erreur sur le pays';
exit;
}
}
// --------------------------------------------------------------------------- //
// getClient
// --------------------------------------------------------------------------- //
function getClient($pays, $service)
{
$service_header = new StdClass;
$service_header->ConsumerId = '006';
$service_header->Provider = new StdClass;
$service_header->Provider->CountryCode = $pays;
$service_header->Provider->ProviderId = getProviderId($pays);
$service_header->TimeStamp = date('Y-m-d\TH:i:s');
$service_header->TestIndication = true;
$soap_header =
new SoapHeader('http://services.giant-net.com/'.
'schema/services/shared/1.0',
'ServiceHeader', $service_header);
$soap_client =
new SoapClient('https://giant-tst.graydon.nl/'.$service.'/v1?wsdl',
array('soap_version' => SOAP_1_1,
'login' => '006',
'password' => 'ClaudeMonet',
'trace' => true));
$soap_client->__setSoapHeaders($soap_header);
return $soap_client;
}
// --------------------------------------------------------------------------- //
// giantErreurSoap
// --------------------------------------------------------------------------- //
function giantErreurSoap(&$client, &$faute, $debug = false)
{
if ($debug == true || DEBUG_SOAP) {
print_r($faute);
print '<br/><br/>';
print 'Requete: '.htmlspecialchars($client->__getLastRequest());
print '<br/><br/>';
print 'Reponse: '.htmlspecialchars($client->__getLastResponse());
} else {
envoieCourriel('SoapFault giantclient',
print_r($faute, true).
'\n\nRequete: '.
htmlspecialchars($client->__getLastRequest()).
'\n\nReponse: '.
htmlspecialchars($client->__getLastResponse()));
print 'Une erreur s\'est produite';
print 'Un courriel a été envoyé à l\'administrateur.';
print 'Veuillez essayer ultérieurement.';
}
}
?>