2009-03-20 09:07:19 +00:00
|
|
|
<?php
|
2009-10-15 15:09:54 +00:00
|
|
|
|
|
|
|
function htmlentitydecode_deep($value)
|
|
|
|
{
|
|
|
|
$value = is_array($value) ?
|
|
|
|
array_map('htmlentitydecode_deep', $value) :
|
2010-09-14 12:54:00 +00:00
|
|
|
html_entity_decode($value, ENT_QUOTES);
|
2009-10-15 15:09:54 +00:00
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
|
2009-07-21 15:08:08 +00:00
|
|
|
$siren = isset($_REQUEST['siren'])? trim($_REQUEST['siren']) : '';
|
2009-03-31 16:11:11 +00:00
|
|
|
$siren = str_replace(' ','',$siren); //Remplacer les espaces
|
2009-03-20 09:07:19 +00:00
|
|
|
|
2010-04-07 14:41:11 +00:00
|
|
|
if ( $siren=='' || strlen($siren)!=14 ) {
|
|
|
|
$output = array(
|
|
|
|
'Siret' => 'Siret incorrect',
|
|
|
|
);
|
|
|
|
echo json_encode($output);
|
|
|
|
exit;
|
|
|
|
}
|
2009-07-21 15:08:08 +00:00
|
|
|
|
2009-03-20 09:07:19 +00:00
|
|
|
$tabEntrep=array();
|
|
|
|
try {
|
2010-01-12 17:34:29 +00:00
|
|
|
$O = $client->getIdentite($siren);
|
2009-03-20 09:07:19 +00:00
|
|
|
$tabEntrep=$O['result'];
|
2009-10-15 15:09:54 +00:00
|
|
|
} catch (SoapFault $fault) {}
|
2009-03-20 09:07:19 +00:00
|
|
|
|
2010-09-14 12:54:00 +00:00
|
|
|
/**
|
|
|
|
* Utiliser la raison sociale la plus longue
|
|
|
|
* Nom, Nom2, NomLong
|
|
|
|
*/
|
|
|
|
if (!empty($tabEntrep['NomLong']) &&
|
|
|
|
strlen($tabEntrep['NomLong'])>strlen($tabEntrep['Nom'])){
|
|
|
|
$tabEntrep['Nom'] = $tabEntrep['NomLong'];
|
|
|
|
}
|
|
|
|
|
2009-03-20 09:07:19 +00:00
|
|
|
//Retourner le tableau sous forme json
|
2009-10-15 15:09:54 +00:00
|
|
|
$tabEntrepD = htmlentitydecode_deep($tabEntrep);
|
2010-06-18 14:52:53 +00:00
|
|
|
echo json_encode($tabEntrepD);
|