Skip to content

Commit

Permalink
🐛 https nao funcionou
Browse files Browse the repository at this point in the history
  • Loading branch information
regisnew committed Apr 16, 2021
1 parent 5d18b33 commit c4d13e6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
31 changes: 14 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
# CNPJ Grátis
[![Travis](https://travis-ci.org/gleisonnanet/cnpj-gratis.svg?branch=2.0)](https://travis-ci.org/gleisonnanet/cnpj-gratis)
[![Latest Stable Version](https://poser.pugx.org/gleisonnanet/cnpj-gratis/v/stable.svg)](https://packagist.org/packages/gleisonnanet/cnpj-gratis)
[![Total Downloads](https://poser.pugx.org/gleisonnanet/cnpj-gratis/downloads.svg)](https://packagist.org/packages/gleisonnanet/cnpj-gratis)
[![Latest Unstable Version](https://poser.pugx.org/gleisonnanet/cnpj-gratis/v/unstable.svg)](https://packagist.org/packages/gleisonnanet/cnpj-gratis)
[![MIT license](https://poser.pugx.org/gleisonnanet/nfephp-serialize/license.svg)](http://opensource.org/licenses/MIT)
<!-- [![Travis](https://travis-ci.org/brk-labs/cnpj-gratis.svg?branch=2.0)](https://travis-ci.org/brk-labs/cnpj-gratis) -->
[![Latest Stable Version](https://poser.pugx.org/brk-labs/cnpj-gratis/v/stable.svg)](https://packagist.org/packages/brk-labs/cnpj-gratis)
[![Total Downloads](https://poser.pugx.org/brk-labs/cnpj-gratis/downloads.svg)](https://packagist.org/packages/brk-labs/cnpj-gratis)
[![Latest Unstable Version](https://poser.pugx.org/brk-labs/cnpj-gratis/v/unstable.svg)](https://packagist.org/packages/brk-labs/cnpj-gratis)
[![MIT license](https://poser.pugx.org/brk-labs/nfephp-serialize/license.svg)](http://opensource.org/licenses/MIT)

Com esse pacote você poderá realizar consultas de CNPJ no site da Receita Federal do Brasil gratuitamente.

Atenção: Esse pacote não possui leitor de captcha, mas captura o mesmo para ser digitado pelo usuário

### Changelog

* 2.1.1 - Bugfix: Atualização site receita. Obrigado @fernandobatels
* 2.1.0 - Removendo dependências extras e versão mínima PHP 5.5
* 2.0.8 - Bugfix: Campo telefone quando não informado. Obrigado @mprandot
* 2.0.7 - Bugfix: Atualização site receita. Obrigado @Marciobds
*1.0.5 correcao do http

### Como utilizar

Adicione a library

```sh
$ composer require gleisonnanet/cnpj-gratis
$ composer require brk-labs/cnpj-gratis
```

Adicione o autoload.php do composer no seu arquivo PHP.
Expand All @@ -33,25 +30,25 @@ require_once 'vendor/autoload.php';
Primeiro chame o método `getParams()` para retornar os dados necessários para enviar no método `consulta()`

```php
$params = gleisonnanet\CnpjGratis\CnpjGratis::getParams();
$params = brk-labs\CnpjGratis\CnpjGratis::getParams();
```

Agora basta chamar o método `consulta()`

```php
$dadosEmpresa = gleisonnanet\CnpjGratis\CnpjGratis::consulta(
$dadosEmpresa = brk-labs\CnpjGratis\CnpjGratis::consulta(
'45.543.915/0001-81',
'INFORME_AS_LETRAS_DO_CAPTCHA',
$params['cookie']
);
```

<!--
### Gostou? Conheça também
* [CpfGratis](https://github.com/gleisonnanet/cpf-gratis)
* [CepGratis](https://github.com/gleisonnanet/cep-gratis)
* [CidadesGratis](https://github.com/gleisonnanet/cidades-gratis)
* [NFePHPSerialize](https://github.com/gleisonnanet/nfephp-serialize)
* [CpfGratis](https://github.com/brk-labs/cpf-gratis)
* [CepGratis](https://github.com/brk-labs/cep-gratis)
* [CidadesGratis](https://github.com/brk-labs/cidades-gratis)
* [NFePHPSerialize](https://github.com/brk-labs/nfephp-serialize) -->

### License

Expand Down
12 changes: 6 additions & 6 deletions src/CnpjGratis.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ class CnpjGratis {
*/
public static function getParams()
{
$data = self::request('https://servicos.receita.fazenda.gov.br/Servicos/cnpjreva/Cnpjreva_Solicitacao.asp');
$data = self::request('http://servicos.receita.fazenda.gov.br/Servicos/cnpjreva/Cnpjreva_Solicitacao.asp');
$cookie = $data['headers']['Set-Cookie'];
$image = self::request('https://servicos.receita.fazenda.gov.br/Servicos/cnpjreva/captcha/gerarCaptcha.asp', [], [
$image = self::request('http://servicos.receita.fazenda.gov.br/Servicos/cnpjreva/captcha/gerarCaptcha.asp', [], [
"Pragma: no-cache",
"Origin: https://www.receita.fazenda.gov.br",
"Origin: http://www.receita.fazenda.gov.br",
"Host: servicos.receita.fazenda.gov.br",
"User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0",
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3",
"Accept-Encoding: gzip, deflate",
"Referer: https://servicos.receita.fazenda.gov.br/Servicos/cnpjreva/Cnpjreva_Solicitacao.asp",
"Referer: http://servicos.receita.fazenda.gov.br/Servicos/cnpjreva/Cnpjreva_Solicitacao.asp",
"Cookie: flag=1; $cookie",
"Connection: keep-alive"
]);
Expand Down Expand Up @@ -57,7 +57,7 @@ public static function consulta($cnpj, $captchaSolved, $cookie)
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Accept-Language: pt-BR,pt;q=0.9,en;q=0.8",
"Accept-Encoding: gzip, deflate",
"Referer: https://servicos.receita.fazenda.gov.br/Servicos/cnpjreva/Cnpjreva_Solicitacao_CS.asp",
"Referer: http://servicos.receita.fazenda.gov.br/Servicos/cnpjreva/Cnpjreva_Solicitacao_CS.asp",
"Cookie: $cookie",
"Connection: keep-alive"
];
Expand All @@ -67,7 +67,7 @@ public static function consulta($cnpj, $captchaSolved, $cookie)
'txtTexto_captcha_serpro_gov_br' => $captchaSolved,
'search_type' => 'cnpj'
];
$data = self::request('https://servicos.receita.fazenda.gov.br/Servicos/cnpjreva/valida.asp', $params, $headers);
$data = self::request('http://servicos.receita.fazenda.gov.br/Servicos/cnpjreva/valida.asp', $params, $headers);
$crawler = new Crawler($data['response']);
if(strpos($crawler->html(), '<b>Erro na Consulta</b>') !== false){
throw new \RuntimeException('Erro ao consultar. Confira se você digitou corretamente os caracteres fornecidos na imagem.', 98);
Expand Down

0 comments on commit c4d13e6

Please sign in to comment.