eccang / open-api
eccang erp open api
v1.1.1
2024-09-24 08:03 UTC
Requires
- php: >=7.2
- psr/container: ^1.0|^2.0
This package is auto-updated.
Last update: 2025-03-24 09:10:43 UTC
README
易仓ERP对外API
环境要求
- PHP >= 7.2
composer安装
安装使用
1.1 Composer 安装
$ composer require eccang/open-api
1.2 下载代码引入
include "eccang/open-api/src/include.php";
服务商应用和自有应用
应用调用统一入口
use Eccang\OpenApi\Contracts\Config; use Eccang\OpenApi\Eccang; use Eccang\OpenApi\System\Request\AppUnityRequest; try { $config = new Config(); $config->setAppKey('AppKey') ->setServiceId('ServiceId') ->setAppScrete('AppScrete') ->setNonceStr('NonceStr') ->setIsDev(); $bizContent = [ 'page' => 1, 'page_size' => 5, ]; $request = new AppUnityRequest(); $request ->setInterfaceMethod('AmazonSettlementReportDataFlatFile') ->setBizContent($bizContent); $response = Eccang::system($config)->appUnity($request); var_dump($response->getData()); var_dump($response->getPage()); var_dump($response->getPageSize()); var_dump($response->getTotal()); } catch (\Exception $exception) { var_dump('error: ' . $exception->getMessage()); }
第三方应用使用
getUserAccessToken
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()); }
getBaseUserInfo
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()); }
getTenantAccessToken
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()); }
应用调用统一入口
use Eccang\OpenApi\Contracts\Config; use Eccang\OpenApi\Eccang; use Eccang\OpenApi\System\Request\AppUnityRequest; try { $config = new Config(); $config->setAppId('AppId') ->setSecret('Secret') ->setIsDev(); $bizContent = [ 'page' => 1, 'page_size' => 2, ]; $request = new AppUnityRequest(); $request->setSubjectCode($subjectCode) ->setToken($tenantAccessToken) ->setSystemName('ERP') ->setVersion('V1.0.0') ->setInterfaceMethod('getOrderList') ->setBizContent($bizContent); $response = Eccang::system($config)->appUnity($request); var_dump($response->getData()); var_dump($response->getPage()); var_dump($response->getPageSize()); var_dump($response->getTotal()); } catch (\Exception $exception) { var_dump('error: ' . $exception->getMessage()); }