1. Go to this page and download the library: Download eccang/open-api 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/ */
eccang / open-api example snippets
php
php
use Eccang\OpenApi\Contracts\Config;
use Eccang\OpenApi\Eccang;
use Eccang\OpenApi\System\Request\UserAccessTokenRequest;
try {
$config = new Config();
$config->setAppId('AppId')
->setSecret('Secret')
->setIsDev();
$code = '8977c0d7e9daec428005cb2a750deedc';
$request = new UserAccessTokenRequest();
$request->setCode($code);
$response = Eccang::system($config)->getUserAccessToken($request);
$userAccessToken = $response->getUserAccessToken();
var_dump('$userAccessToken: ' . $userAccessToken);
} catch (\Exception $exception) {
var_dump('error: ' . $exception->getMessage());
}
php
use Eccang\OpenApi\Contracts\Config;
use Eccang\OpenApi\Eccang;
use Eccang\OpenApi\System\Request\BaseUserInfoRequest;
try {
$config = new Config();
$config->setAppId('AppId')
->setSecret('Secret')
->setIsDev();
$request = new BaseUserInfoRequest();
$request->setToken($userAccessToken);
$response = Eccang::system($config)->getBaseUserInfo($request);
$subjectCode = $response->getSubjectCode();
var_dump('$subjectCode: ' . $subjectCode);
} catch (\Exception $exception) {
var_dump('error: ' . $exception->getMessage());
}
php
use Eccang\OpenApi\Contracts\Config;
use Eccang\OpenApi\Eccang;
use Eccang\OpenApi\System\Request\TenantAccessTokenRequest;
try {
$config = new Config();
$config->setAppId('AppId')
->setSecret('Secret')
->setIsDev();
$request = new TenantAccessTokenRequest();
$request->setSubjectCode($subjectCode);
$response = Eccang::system($config)->getTenantAccessToken($request);
$tenantAccessToken = $response->getTenantAccessToken();
var_dump('$tenantAccessToken: ' . $tenantAccessToken);
} catch (\Exception $exception) {
var_dump('error: ' . $exception->getMessage());
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.