Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0 #41

Open
wants to merge 50 commits into
base: 1.0
Choose a base branch
from
Open

1.0 #41

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
151f027
Merge branch '1.0'
jansenfelipe Oct 22, 2014
b5cbe48
Inclusão dos cases Telefone, Endereço Eletrônico e Ente Federativo nã…
filipegar Jan 19, 2015
8c8ad30
Merge pull request #9 from epilif09/1.0
jansenfelipe Jan 19, 2015
151a2ef
Remoção phpQuery
jansenfelipe Jan 19, 2015
cfc4578
Remoção phpQuery-onefile
jansenfelipe Jan 19, 2015
61ffc0a
Retornar link audio
jansenfelipe Jan 20, 2015
4dc3c62
Atendendo sugestão @rafaelwithoeft : Tratamento CNPJ válido porém não…
jansenfelipe Jan 20, 2015
dee9481
Update readme
jansenfelipe Jan 20, 2015
df825fa
Update min version PHP
jansenfelipe Jan 20, 2015
f867a6a
Update README.md
jansenfelipe Jan 20, 2015
8a9c4ba
Já fazendo a requisição re retornando o binario do áudio
jansenfelipe Jan 21, 2015
3a8f20c
Merge branch 'master' into 2.0
jansenfelipe Jan 21, 2015
805cb0c
Update README.md
jansenfelipe Feb 5, 2015
a656310
#10 Fix
jansenfelipe Feb 13, 2015
d53fadc
Update README.md
jansenfelipe Feb 13, 2015
2ebac7c
Merge branch 'master' into 2.0
jansenfelipe Feb 13, 2015
60784dd
Testando se o captcha foi capturado
jansenfelipe Feb 27, 2015
9226b24
Merge branch 'master' into 2.0
jansenfelipe Feb 27, 2015
6d85663
Require GD extension
jansenfelipe Mar 4, 2015
3b3a2dc
Update README.md
jansenfelipe Apr 1, 2015
6881e67
Update README.md
jansenfelipe Apr 1, 2015
7ec964f
Update README.md
jansenfelipe Apr 1, 2015
7719e13
Update composer.json
jansenfelipe Apr 11, 2015
3423de9
Update README.md
jansenfelipe Jul 12, 2015
ad9a8ad
Update README.md
jansenfelipe Jul 12, 2015
ac33847
Update
jansenfelipe Jul 12, 2015
41d01f6
Update composer.json
jansenfelipe Jul 13, 2015
2698481
Update README.md
jansenfelipe Jul 24, 2015
0971deb
Update README.md
jansenfelipe Sep 14, 2015
218a97c
Capturar campo Data de Abertura
Dec 26, 2015
32ed8ba
Merge pull request #15 from matheusdev/2.0
jansenfelipe Dec 26, 2015
44a73f6
Update README.md
jansenfelipe Jan 8, 2016
17bdcb6
Separação de campo telefone com 2 telefones
Feb 25, 2016
5462341
Merge pull request #18 from JRAVILES/JRAVILES-patch-1
jansenfelipe Mar 16, 2016
48aa945
Por algum motivo a biblioteca não consegue filtrar as informações, ad…
Marciobds Jul 13, 2016
a1e53af
Merge pull request #24 from Marciobds/patch-1
jansenfelipe Jul 13, 2016
13e8ccd
Problema undefined index telefone
mprandot Jul 15, 2016
2bce6dc
Merge pull request #26 from mprandot/patch-1
jansenfelipe Jul 16, 2016
f8f00b9
Update README.md
jansenfelipe Jul 18, 2016
f749646
Adição de checagem do conteúdo de retorno da Receita. A existência de…
Jul 26, 2016
6bd6176
Merge pull request #27 from garimpeirodouniverso/2.0
jansenfelipe Jul 26, 2016
da7b83b
Remove goutte require
jansenfelipe Mar 16, 2017
9fbcc29
Update
jansenfelipe Mar 16, 2017
2d77445
fix travis
jansenfelipe Mar 16, 2017
ab283d6
Atualização do site da receita
fernandobatels Aug 30, 2018
233e86b
Merge branch 'fernandobatels-2.1' into 2.1
jansenfelipe Oct 17, 2018
33790e8
Update README.md
jansenfelipe Oct 17, 2018
db6010f
Atualizando e refatorando
gleisonnanet Dec 26, 2019
d5960cd
Atualizando e refatorando
gleisonnanet Dec 26, 2019
317c3ea
version 1.0
gleisonnanet Dec 26, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- hhvm
Expand All @@ -13,4 +11,4 @@ before_script:

script:
- mkdir -p build/logs
- vendor/bin/phpunit -c phpunit.xml.dist --verbose
- vendor/bin/phpunit -c phpunit.xml.dist --verbose
75 changes: 36 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,58 @@
# CNPJ Grátis
[![Travis](https://travis-ci.org/jansenfelipe/cnpj-gratis.svg?branch=1.0)](https://travis-ci.org/jansenfelipe/cnpj-gratis)
[![Latest Stable Version](https://poser.pugx.org/jansenfelipe/cnpj-gratis/v/stable.svg)](https://packagist.org/packages/jansenfelipe/cnpj-gratis) [![Total Downloads](https://poser.pugx.org/jansenfelipe/cnpj-gratis/downloads.svg)](https://packagist.org/packages/jansenfelipe/cnpj-gratis) [![Latest Unstable Version](https://poser.pugx.org/jansenfelipe/cnpj-gratis/v/unstable.svg)](https://packagist.org/packages/jansenfelipe/cnpj-gratis) [![License](https://poser.pugx.org/jansenfelipe/cnpj-gratis/license.svg)](https://packagist.org/packages/jansenfelipe/cnpj-gratis)

[![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)

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

### Como usar
### Changelog

Adicione no seu arquivo `composer.json` o seguinte registro na chave `require`
* 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

"jansenfelipe/cnpj-gratis": "1.0.*@dev"
### Como utilizar

Execute
Adicione a library

$ composer update
```sh
$ composer require gleisonnanet/cnpj-gratis
```

Adicione o autoload.php do composer no seu arquivo PHP.

require_once 'vendor/autoload.php';
```php
require_once 'vendor/autoload.php';
```

Primeiro chame o método `getParams()` para retornar os dados necessários para enviar no método `consulta()`

$params = CnpjGratis::getParams(); //Output: array('captcha', 'captchaBase64', 'viewstate', 'cookie')

Agora chame o método `consulta()`

$dadosEmpresa = CnpjGratis::consulta(
'45.543.915/0001-81',
'INFORME_AS_LETRAS_DO_CAPTCHA',
$params['viewstate'],
$params['cookie']
);


### Frameworks

##### (Laravel)

Abra seu arquivo `config/app.php` e adicione `'JansenFelipe\CnpjGratis\CnpjGratisServiceProvider'` ao final do array `$providers`
```php
$params = gleisonnanet\CnpjGratis\CnpjGratis::getParams();
```

'providers' => array(
Agora basta chamar o método `consulta()`

'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
...
'JansenFelipe\CnpjGratis\CnpjGratisServiceProvider',
),
```php
$dadosEmpresa = gleisonnanet\CnpjGratis\CnpjGratis::consulta(
'45.543.915/0001-81',
'INFORME_AS_LETRAS_DO_CAPTCHA',
$params['cookie']
);
```

Adicione também `'CnpjGratis' => 'JansenFelipe\CnpjGratis\Facade'` no final do array `$aliases`
### Gostou? Conheça também

'aliases' => array(
* [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)

'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
...
'CnpjGratis' => 'JansenFelipe\CnpjGratis\Facade',
### License

),
The MIT License (MIT)
32 changes: 17 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
{
"name": "jansenfelipe/cnpj-gratis",
"name": "gleisonnanet/cnpj-gratis",
"description": "Com esse pacote você poderá consultar, gratuitamente, CNPJs diretamente no site da receita.",
"keywords": ["laravel", "cnpj", "php"],
"keywords": ["consulta", "receita", "cnpj", "php"],
"license": "MIT",
"authors": [
{
"name": "Jansen Felipe",
"email": "jansen.felipe@gmail.com"
"name": "Gleison de souza luiz",
"email": "gleisonnanet@gmail.com"
}
],
"require": {
"php": ">=5.3.0",
"jansenfelipe/utils": "1.0.*@dev"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
"php": "^7.0",
"symfony/dom-crawler": "^5.0",
"symfony/css-selector": "^5.0",
"ext-gd":"*",
"ext-curl":"*",
"gleisonnanet/utils": "^2.0"
},

"autoload": {
"psr-0": {
"JansenFelipe\\CnpjGratis": "src/"
"psr-4": {
"gleisonnanet\\CnpjGratis\\": "src/"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "1.0"
}
},
"suggest": {
"jansenfelipe/cpf-gratis": "Permite consulta de CPF no site da receita",
"jansenfelipe/cep-gratis": "Permite consulta de CEP no site dos Correios"
"gleisonnanet/cpf-gratis": "Permite consulta de CPF no site da receita",
"gleisonnanet/cep-gratis": "Permite consulta de CEP no site dos Correios"
},
"minimum-stability": "dev"
"minimum-stability": "stable"
}
25 changes: 25 additions & 0 deletions example/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

require_once '../vendor/autoload.php';

use gleisonnanet\CnpjGratis\CnpjGratis;


if(isset($_POST['captcha']) && isset($_POST['cookie']) && isset($_POST['cnpj'])){
$dados = CnpjGratis::consulta($_POST['cnpj'], $_POST['captcha'], $_POST['cookie']);
var_dump($dados);
die;
}else
$params = CnpjGratis::getParams();
?>

<img src="data:image/png;base64,<?php echo $params['captchaBase64'] ?>" />

<form method="POST">
<input type="hidden" name="cookie" value="<?php echo $params['cookie'] ?>" />

<input type="text" name="captcha" placeholder="Captcha" />
<input type="text" name="cnpj" placeholder="CNPJ" />

<button type="submit">Consultar</button>
</form>
6 changes: 3 additions & 3 deletions formTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
require 'vendor/autoload.php';

if (isset($_POST['cnpj'])) {
var_dump(\JansenFelipe\CnpjGratis\CnpjGratis::consulta($_POST['cnpj'], $_POST['captcha'], $_POST['viewstate'], $_POST['cookie']));
var_dump(\gleisonnanet\CnpjGratis\CnpjGratis::consulta($_POST['cnpj'], $_POST['captcha'], $_POST['cookie']));
die;
}

$cnpj = '45543915000858';

$params = \JansenFelipe\CnpjGratis\CnpjGratis::getParams();
$params = \gleisonnanet\CnpjGratis\CnpjGratis::getParams();

?>


Expand All @@ -18,6 +19,5 @@
<input type="text" name="cnpj" value="<?php echo $cnpj; ?>" />
<input type="text" name="captcha" />
<input type="text" name="cookie" value="<?php echo $params['cookie']; ?>" />
<textarea name="viewstate"><?php echo $params['viewstate']; ?></textarea>
<input type="submit" />
</form>
Loading