flyingluscas / correios-php
轻松与邮政的主要功能交互。
v2.4.0
2020-11-01 03:59 UTC
Requires
- php: ~5.6|~7.0
- guzzlehttp/guzzle: ~7.2|~6.5
Requires (Dev)
- phpunit/phpunit: ~5.7
- squizlabs/php_codesniffer: ~3.5
README
轻松与 邮政 的主要功能交互。
功能
安装
通过Composer
$ composer require flyingluscas/correios-php
使用
查询CEP
通过直接查询邮政的 Web服务,根据CEP查找地址。
use FlyingLuscas\Correios\Client; require 'vendor/autoload.php'; $correios = new Client; $correios->zipcode() ->find('01001-000'); /* Resultado: [ 'zipcode' => '01001-000', 'street' => 'Praça da Sé', 'complement' => [ 'lado ímpar', ], 'district' => 'Sé', 'city' => 'São Paulo', 'uf' => 'SP', ] */
计算价格和期限
计算配送服务的价格和期限(Sedex、PAC等),支持在同一查询中支持多个对象。
use FlyingLuscas\Correios\Client; use FlyingLuscas\Correios\Service; require 'vendor/autoload.php'; $correios = new Client; $correios->freight() ->origin('01001-000') ->destination('87047-230') ->services(Service::SEDEX, Service::PAC) ->item(16, 16, 16, .3, 1) // largura, altura, comprimento, peso e quantidade ->item(16, 16, 16, .3, 3) // largura, altura, comprimento, peso e quantidade ->item(16, 16, 16, .3, 2) // largura, altura, comprimento, peso e quantidade ->calculate(); /* Resultados: [ [ 'name' => 'Sedex', 'code' => 40010, 'price' => 51, 'deadline' => 4, 'error' => [], ], [ 'name' => 'PAC', 'code' => 41106, 'price' => 22.5, 'deadline' => 9, 'error' => [], ], ] */
变更日志
查看 CHANGELOG 获取最近更改的更多信息。
测试
$ composer test
贡献
查看 CONTRIBUTING 获取更多详细信息。
安全
如果您发现任何与安全相关的问题,请发送电子邮件至 lucas.pires.mattos@gmail.com 而不是使用问题跟踪。
致谢
许可证
MIT许可证(MIT)。有关更多信息,请参阅 许可证文件。