laxinplus / openapi-php-sdk
LanXin+ OpenAPI Platform
1.0.0
2021-10-18 08:19 UTC
Requires
- php: ^7.3 || ^8.0
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^6.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.12
- phpunit/phpunit: ^8.0 || ^9.0
This package is not auto-updated.
Last update: 2025-01-02 14:11:55 UTC
README
关于
运行环境
- PHP 7.3 及以上
安装方法
方式一:
- 如果您使用composer管理项目依赖项,请在您的项目根目录中运行以下命令:
composer require laxinplus/openapi-php-sdk
- 您也可以在composer.json文件中声明对 PHP 的蓝信 PHP SDK 的依赖
"require": {
"laxinplus/openapi-php-sdk": "~1.0"
}
- 然后运行composer install以安装依赖项。安装 Composer Dependency Manager 后,在 PHP 代码中导入依赖项:
require_once __DIR__ . '/vendor/autoload.php';
方式二:
- 下载SDK源码,可执行
composer install
生成 autoload.php文件:
require_once('/path/to/lanxinplus-openapi-php-sdk/vendor/autoload.php');
快速使用
获取 APP_TOKEN
<?php require_once(__DIR__ . '/vendor/autoload.php'); use \GuzzleHttp\Client; $host = "host"; // 蓝信开放平台网关地址, e.g.: https://example.com/open/apigw $appId = "appId"; // 应用ID, e.g.: 1234567-7654321 $appSecret = "appSecret"; // 应用密钥, e.g.: D25F65E65D887AEFD9C92B00310286FA $config = new LanXinPlusOpenAPI\Configuration($host, $appId, $appSecret); $api = new LanXinPlusOpenAPI\Api\AuthApi(new Client(), $config); $resp = $api->V1ApptokenCreate("client_credential" ,$appId, $appSecret); print_r($resp);
测试用例使用说明
运行test
composer install ./vendor/bin/phpunit test/api/AuthApiTest.php