PHP code example of caobowen / kimi-nexus
1. Go to this page and download the library: Download caobowen/kimi-nexus library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
caobowen / kimi-nexus example snippets
use KimiNexus\Core\ApiConfig;
use KimiNexus\Integrations\BusinessGovtNz\BusinessGovtNzGateway;
$baseUri = getenv('BUSINESS_GOVTNZ_BASE_URI') ?: 'https://api.business.govt.nz/';
$timeout = (float) (getenv('BUSINESS_GOVTNZ_TIMEOUT') ?: 20);
$subscriptionKey = getenv('BUSINESS_GOVTNZ_PRIMARY_KEY') ?: getenv('BUSINESS_GOVTNZ_SECONDARY_KEY');
$config = new ApiConfig($baseUri, null, $timeout, [
'Ocp-Apim-Subscription-Key' => (string) $subscriptionKey,
]);
$client = BusinessGovtNzGateway::make($config);
// 示例接口:不发真实 HTTP,请求结果固定返回 helloworld
$result = $client->helloWorld();
var_dump($result);
// NZBN 按名称搜索实体
$entities = $client->searchEntitiesByName('acme', [
'entity_status' => ['Registered', 'VoluntaryAdministration'],
'entity_type' => ['NZCompany', 'OverseasCompany'],
'industry_code' => 'M692250',
'page' => 0,
'page_size' => 20,
]);
var_dump($entities);
// NZBN 查单个实体详情
$entity = $client->viewEntityByNzbn('9429040000000', [
'request_id' => '2a444f3f-a486-4f7c-9bcf-e02095fd3576', // 可选,对应 api-business-govt-nz-Request-Id
'if_none_match' => 'W/"previous-etag"', // 可选,对应 If-None-Match
]);
var_dump($entity);
use KimiNexus\Core\ApiConfig;
use KimiNexus\Integrations\BusinessGovtNz\BusinessGovtNzGateway;
$baseUri = getenv('BUSINESS_GOVTNZ_BASE_URI') ?: 'https://api.business.govt.nz/';
$timeout = (float) (getenv('BUSINESS_GOVTNZ_TIMEOUT') ?: 20);
$subscriptionKey = getenv('BUSINESS_GOVTNZ_PRIMARY_KEY') ?: getenv('BUSINESS_GOVTNZ_SECONDARY_KEY');
$config = new ApiConfig($baseUri, null, $timeout, [
'Ocp-Apim-Subscription-Key' => (string) $subscriptionKey,
]);
$client = BusinessGovtNzGateway::make($config);
$entities = $client->searchEntitiesByName('acme', [
'entity_status' => ['Registered'],
'page' => 0,
'page_size' => 5,
]);
$firstNzbn = $entities['data']['items'][0]['nzbn'] ?? null;
if ($firstNzbn !== null) {
$detail = $client->viewEntityByNzbn($firstNzbn);
var_dump($detail);
}
use KimiNexus\Core\ApiConfig;
use KimiNexus\Integrations\AbnLookup\AbnLookupGateway;
$baseUri = getenv('ABN_LOOKUP_BASE_URI') ?: 'https://abr.business.gov.au/json/';
$timeout = (float) (getenv('ABN_LOOKUP_TIMEOUT') ?: 20);
$guid = (string) getenv('ABN_LOOKUP_GUID');
$config = new ApiConfig($baseUri, null, $timeout);
$client = AbnLookupGateway::make($config, $guid);
// 1) 按 ABN 查询
$byAbn = $client->searchByAbn('51 824 753 556');
// 2) 按名称模糊查询
$byName = $client->searchByName('COMMONWEALTH BANK', 20, false);