infradigital / api-client
Infra Digital Nusantara APIs 客户端适配器
v1.1
2019-01-14 02:37 UTC
Requires
- php: >=5.6
- php-http/cache-plugin: ^1.2
- php-http/client-common: ^1.3
- php-http/client-implementation: ^1.0
- php-http/discovery: ^1.0
- php-http/httplug: ^1.1
- php-http/logger-plugin: ^1.0
- psr/cache: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- fzaninotto/faker: ^1.8
- guzzlehttp/psr7: ^1.2
- php-http/guzzle6-adapter: ^1.0
- phpunit/phpunit: ^4.0 || ^5.5
This package is auto-updated.
Last update: 2024-09-19 22:04:37 UTC
README
INFRA DIGITAL NUSANTARA APIs
这是一个用于向 IDN 端点发起请求的 API 库。
您可以通过 composer 安装此库。您可以使用以下命令安装此库 composer require infradigital/api-client
或将库的 Packagist 命名空间注册到您的 composer.json 文件中 { "require": { "infradigital/api-client": "1.*" } }
然后调用 composer install 命令 php composer install
如何使用
要初始化 API 类,您首先可以导入 ApiClient 类,如下所示 use InfraDigital\ApiClient;
然后在您的 PHP 代码中初始化它
$idnClient = new ApiClient\Client($idnUserName, $idnPassword);
一旦初始化了类,您就可以像以下示例那样使用它
$idnClient->studentApi()->createStudent('Test User 1234' . date('YMDhis'), 'testBillKey01234' . date('YMDhis'),'0987612345', 'use.only@valid.domain', 'This is test to create user');
如果我们把它们放在一起,就会看起来像这样
use InfraDigital\ApiClient;
$idnClient = new ApiClient\Client($idnUserName, $idnPassword);
$idnClient->studentApi()->createStudent('Test User 1234' . date('YMDhis'), 'testBillKey01234' . date('YMDhis'),'0987612345', 'use.only@valid.domain', 'This is test to create user');
您可以在初始化类后使用以下简短代码 $idnClient->setDevMode();
。这样,它将默认使用 IDN 生产域作为 uri。
$idnClient = new ApiClient\Client($idnUserName, $idnPassword);
$idnClient->setDevMode(); // This will be tell the class to use development uri
$idnClient->studentApi()->createStudent('Test User 1234' . date('YMDhis'), 'testBillKey01234' . date('YMDhis'),'0987612345', 'use.only@valid.domain', 'This is test to create user');