gusapi / gusapi
Gus Api Library for PHP
6.2.0
2023-10-09 09:14 UTC
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.11
- phpstan/phpstan: ^1.8
- phpstan/phpstan-phpunit: ^1.1
- phpunit/phpunit: ^9.0
- rector/rector: ^0.14.6
- squizlabs/php_codesniffer: ^3.7
README
PHP GUS API 是一个面向对象的库,用于通过基于 官方 REGON SOAP API 的 REGON 网站获取信息。官方 GUS 文档在此。
安装
此库使用 Composer,只需输入
composer require gusapi/gusapi
支持的版本
如果您仍然使用 PHP <= 8.0,请参阅 5.x 版本的文档在此
从 5.x 升级到 6.x
更多信息请参阅 UPGRADE.md。
6.x 版本示例
请参阅文件 examples/readmeExample.php。
require_once '../vendor/autoload.php'; use GusApi\Exception\InvalidUserKeyException; use GusApi\Exception\NotFoundException; use GusApi\GusApi; use GusApi\ReportTypes; use GusApi\BulkReportTypes; $gus = new GusApi('your api key here'); //for development server use: //$gus = new GusApi('abcde12345abcde12345', 'dev'); try { $nipToCheck = 'xxxxxxxxxx'; //change to valid nip value $gus->login(); $gusReports = $gus->getByNip($nipToCheck); var_dump($gus->dataStatus()); var_dump($gus->getBulkReport( new DateTimeImmutable('2019-05-31'), BulkReportTypes::REPORT_DELETED_LOCAL_UNITS )); foreach ($gusReports as $gusReport) { //you can change report type to other one $reportType = ReportTypes::REPORT_PERSON; echo $gusReport->getName(); echo 'Address: ' . $gusReport->getStreet() . ' ' . $gusReport->getPropertyNumber() . '/' . $gusReport->getApartmentNumber(); $fullReport = $gus->getFullReport($gusReport, $reportType); var_dump($fullReport); } } catch (InvalidUserKeyException $e) { echo 'Bad user key'; } catch (NotFoundException $e) { echo 'No data found <br>'; echo 'For more information read server message below: <br>'; echo sprintf( "StatusSesji:%s\nKomunikatKod:%s\nKomunikatTresc:%s\n", $gus->getSessionStatus(), $gus->getMessageCode(), $gus->getMessage() ); }
捐赠
如果这个项目帮助您减少了开发时间,您可以通过一杯咖啡来支持我 ;)
PayPal 捐赠