Skip to content

Instantly share code, notes, and snippets.

@notelseit
Forked from camilamoreiradev/Pegar dados da empresa
Created February 3, 2023 06:28
Show Gist options
  • Select an option

  • Save notelseit/8784a162c7a346d3b9258ea62e23679e to your computer and use it in GitHub Desktop.

Select an option

Save notelseit/8784a162c7a346d3b9258ea62e23679e to your computer and use it in GitHub Desktop.
$cnpj = {cnpj};
$webservice = "https://www.receitaws.com.br/v1/cnpj/".$cnpj;
$consulta = file_get_contents($webservice);
$retorno = json_decode($consulta,true);
if($retorno["status"] == "OK") {
if($retorno["situacao"] == "ATIVA") {
{razao_social} = $retorno["nome"];
{nome_fantasia} = $retorno["fantasia"];
{cep} = str_replace(".", "", str_replace("-", "", $retorno["cep"]));
{endereco} = $retorno["logradouro"];
{numero} = $retorno["numero"];
{complemento} = $retorno["complemento"];
{bairro} = $retorno["bairro"];
{cidade} = $retorno["municipio"];
{estado} = $retorno["uf"];
{telefone} = str_replace("(", "", str_replace(")", "", str_replace("-", "", $retorno["telefone"])));
{email} = $retorno["email"];
} else {
sc_alert("Empresa inativa!");
}
} else {
sc_alert($retorno["message"]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment