prhost / cep-gratis
使用此包,您可以免费进行CEP查询。
v5.0.11
2023-06-15 13:33 UTC
Requires
- php: >=7.1
- ext-curl: *
- symfony/css-selector: ^3.4|^4.3|^5
- symfony/dom-crawler: ^3.4|^4.3|^5.7
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2024-09-15 16:58:56 UTC
README
使用此包,您可以免费进行CEP查询。
为了避免服务不可用的问题,查询将在不同的提供商上并行进行
库将返回给您最快的响应,从而提高查询性能。
如何使用
添加库
$ composer require Prhost/cep-gratis
将composer的autoload.php添加到您的PHP文件中。
require_once 'vendor/autoload.php';
现在只需调用CepGratis::search($cep)
方法
use Prhost\CepGratis\CepGratis; $address = CepGratis::search('31030080');
传递选项(如CEP Aberto的token)的示例
use Prhost\CepGratis\CepGratis; $cep = '31030080'; $options = ['token' => '123abc']; $timeout = 15; //segundos $address = CepGratis::search($cep, $options, $timeout);
其他方法
use Prhost\CepGratis\CepGratis; use Prhost\CepGratis\Providers\CepAbertoProvider; $cepGratis = new CepGratis(); $cepGratis->setOptions(['token' => '123abc']); $cepGratis->addProvider(new CepAbertoProvider()); $cepGratis->setTimeout(15); $address = $cepGratis->resolve('31030080');
许可证
MIT许可证(MIT)