banguncode/php-icare
Composer 安装命令:
composer require banguncode/php-icare
包简介
A simple PHP library for accessing the healthcare history of JKN participants.
README 文档
README
A simple PHP library for accessing the healthcare history of JKN (Jaminan Kesehatan Nasional) participants via BPJS Kesehatan Icare API.
This library also supports fetching verification and approval data from the Mobile Faskes API.
Features
- Access healthcare history of JKN participants by NIK or BPJS Participant Number.
- Automatic API signature generation (HMAC-SHA256).
- Response decryption using AES-256-CBC and LZString compression.
- Retrieve verification and approval status from Mobile Faskes.
- Retry mechanism for API responses with delay instructions.
- Simple logging example included.
Requirements
- PHP >= 5.5
- Composer
- PHP extensions:
ext-curlext-openssl
Installation
Install via Composer:
composer require banguncode/php-icare
Usage Example
<?php require __DIR__ . '/vendor/autoload.php'; use PHPIcare\Icare; // Set your BPJS API credentials defined("JKN_API_CONSID") or define("JKN_API_CONSID", "your_consid"); defined("JKN_API_SECRET") or define("JKN_API_SECRET", "your_secret"); defined("JKN_API_USERKEY") or define("JKN_API_USERKEY", "your_userkey"); // Initialize $icare = (new Icare())->init(JKN_API_CONSID, JKN_API_SECRET, JKN_API_USERKEY); // Example data $data = [ ['param' => '1234567890000000', 'kodedokter' => '12345'], ['param' => '0000012345678', 'kodedokter' => '67890'], ]; $total = count($data); echo "Total data: {$total}\n"; // Log file setup $logDir = __DIR__ . '/logs'; if (!is_dir($logDir)) { mkdir($logDir, 0777, true); } $logFile = $logDir . '/' . date('Y-m-d') . '.log'; foreach ($data as $key => $row) { printf("%d/%d\n", $key + 1, $total); $param = !empty($row['param']) && preg_match('/^\d+$/', $row['param']) ? $row['param'] : null; $kodedokter = isset($row['kodedokter']) ? $row['kodedokter'] : null; $response = $icare->getIcareHistory($param, $kodedokter); $logMsg = ''; if ($response) { if (is_int($response)) { $time = $response; while ($time > 0) { echo "Retry in {$time} s\n"; sleep(1); $time--; } $response = $icare->getIcareHistory($param, $kodedokter); } $verif = $icare->getCekVerifikasi3($response); $approval = $icare->postApprovalIC($response); $logMsg .= "Request {$param} - {$kodedokter} success!\n"; $logMsg .= "[REFERER] {$response}\n"; $logMsg .= "[VERIF] {$verif}\n"; $logMsg .= "[APPROVAL] {$approval}\n"; } else { $logMsg .= "Request {$param} - {$kodedokter} failed!\n"; } $logMsg .= "\n"; echo $logMsg; file_put_contents($logFile, $logMsg, FILE_APPEND); sleep(5); } echo "Done!";
Reference
init(string $consId, string $secret, string $userKey): self
Initialize the library with your BPJS API credentials.
getIcareHistory(string $param, string $kodedokter): string|int|null|false
Fetch healthcare history data from Icare.
- Returns a URL string on success.
- Returns an integer (seconds to wait) if API requests a retry.
- Returns null if no valid response.
- Returns false if an error occurs.
getCekVerifikasi3(string $referer): array|null|false
Fetch verification data from Mobile Faskes using a referer URL.
postApprovalIC(string $referer): string|null|false
Submit an approval request to Mobile Faskes using a referer URL.
wsDecrypt(string $string): string|null
Decrypts AES-256-CBC encoded and LZString-compressed API data.
License
MIT License © 2025
Disclaimer
This library is not affiliated with BPJS Kesehatan. You must be an authorized user with valid credentials to use the BPJS Kesehatan API, and you are responsible for complying with all applicable regulations.
banguncode/php-icare 适用场景与选型建议
banguncode/php-icare 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 08 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「bpjs」 「bridging」 「icare」 「jkn」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 banguncode/php-icare 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 banguncode/php-icare 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 banguncode/php-icare 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Package for integrate with BPJS Trustmark
A Laravel package to simplify the integration with BPJS e-Klaim web service. This package helps developers build APIs to interact with the e-Klaim system, providing features such as custom SHA-256 encryption and decryption, type-checking for incoming data, and more.
A simple PHP library for BPJS Kesehatan facial recognition integration.
A simple PHP library for BPJS Kesehatan fingerprint integration.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-13