mrhd/jstan

聚水潭sdk-php

v1.0.0 2024-03-07 13:12 UTC

This package is not auto-updated.

Last update: 2025-03-21 16:54:24 UTC


README

介绍

聚水潭php-sdk

遇到问题先去查阅官方文档 聚水潭文档

要求

  • php >= 7.4(其他 php 版本理论支持,但是未经过测试,请自行修改 php 版本号)

安装

composer require mrhd/jstan

laravel 使用移步至 laravel-jushuitan

配置

如果下面的示例比较晦涩,请查看测试用例

config全局配置

$isProd = env('STAN_IS_PROD',true);
private array $config = [
    //是否正式环境
    'isProd' => $isProd,
    // 服务商授权拼接地址
    'authUrl' => $isProd?env('STAN_AUTH_URL', 'https://openweb.jushuitan.com/auth'):'https://isv-openweb.jushuitan.com/auth',
    // (服务商和自研)获取access_token和自研用refresh_token刷新access_token地址,服务商不支持刷新access_token
    // 接口地址
    'apiUrl' => $isProd?env('STAN_API_URL','https://openapi.jushuitan.com/'):'https://dev-api.jushuitan.com/',
    // 授权token
    'accessToken' => $isProd?env('STAN_ACCESS_TOKEN',''):'',
    // 应用key
    'appKey' =>$isProd?env('STAN_APP_KEY',''):'',
    // 应用secret
    'appSecret' => $isProd?env('STAN_APP_SECRET',''):'',
    // 版本号
    'version' => '2',
    // 字符集
    'charset' => 'utf-8',
    // 是否验证证书
    'verify' => env('STAN_VERIFY',false),
    // 超时时间
    'timeout' => env('STAN_TIMEOUT',0)
];

api调用

use JsTan\Client;
use JsTan\Route;

/****/

$client = Client::getInstance($this->config);
$route = Route::getInstance();


//路由可使用 Route::QUERY_SHOPS || $route->getRoute('QUERY_SHOPS') || 'open/logisticscompany/query'
// 常量传入,getRoute 传入,字符串传入,看自己喜好

/**
* 查询门店列表(请求示例)
*/
$response = $client->request($route->getRoute('QUERY_SHOPS'), [
  'page_index' => 1,
  'page_size' => 10
]);


/**
* 获取access_token (请求示例)
*/
$response = $client->getAccessToken('001');


/**
* 刷新access_token (请求示例)
*/
$response = $client->refreshToken('001');


print_r($response);

License

JsTan is made available under the MIT License (MIT). Please see License File for more information.