Skip to content

Instantly share code, notes, and snippets.

@tuxity
Created July 21, 2013 12:34
Show Gist options
  • Save tuxity/6048429 to your computer and use it in GitHub Desktop.
Save tuxity/6048429 to your computer and use it in GitHub Desktop.
Search into website societe.com if a SIRET exists or not. Other solutions exists like with http://ec.europa.eu/taxation_customs/index_fr.htm
<?php
/*
* Search into website societe.com if a SIRET exists or not
*/
function SIRETExists($checkSIRET)
{
$checkRCS = substr($checkSIRET, 0, 9);
$retURL = @file_get_contents("http://www.societe.com/cgi-bin/recherche?rncs=".$checkRCS);
if (empty($retURL))
return FALSE;
if (preg_match("/Erreur de formulaire./", $retURL))
return FALSE;
else
{
preg_match("/SIRET.*([0-9]{14})/ms", $retURL, $matches);
if ($checkSIRET === $matches[1])
return TRUE;
else
return FALSE;
}
}
/* Test part */
echo SIRETExists("0123456789")."\n";
echo SIRETExists("78861862700012")."\n";
echo SIRETExists("75130154000017")."\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment