prhost/cep-gratis

使用此包,您可以免费进行CEP查询。

维护者

详细信息

github.com/prhost/cep-gratis

源代码

安装数: 2,286

依赖项: 0

建议者: 0

安全性: 0

星标: 3

关注者: 1

分支: 32

语言:HTML

v5.0.11 2023-06-15 13:33 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)