含 AI 助手、抖音 OAuth、流量池推送、支付获客、SuperAdmin 设备与场景管理等本地迭代;以本地为准单向推送,未拉取远程。 Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
||
/**
|
||
* 开放对接平台 · 鉴权入口
|
||
* POST /v1/open/auth/token → 用 apiKey + sign + timestamp 换取 JWT
|
||
*
|
||
* 文档:开发文档/5、接口/08-存客宝开放对接平台/02-鉴权与签名规范.md
|
||
*
|
||
* @package app\common\controller
|
||
*/
|
||
|
||
namespace app\common\controller;
|
||
|
||
use app\common\service\OpenPlatformService;
|
||
use library\ResponseHelper;
|
||
use think\Controller;
|
||
use think\facade\Request;
|
||
|
||
class OpenAuthController extends Controller
|
||
{
|
||
/**
|
||
* 颁发开放 Token
|
||
*
|
||
* 入参:
|
||
* apiKey string 应用密钥(=customer_acquisition_task.apiKey)
|
||
* sign string 双 MD5 签名
|
||
* timestamp int 秒级时间戳,±300s
|
||
*
|
||
* 出参:
|
||
* { code:200, msg:success, data:{ token, expireIn, planId, planName, companyId } }
|
||
*/
|
||
public function getToken()
|
||
{
|
||
$params = Request::param();
|
||
$result = OpenPlatformService::issueToken($params);
|
||
|
||
if (($result['code'] ?? 0) !== 200) {
|
||
return ResponseHelper::error($result['msg'] ?? 'auth failed', $result['code'] ?? 400);
|
||
}
|
||
|
||
$data = [
|
||
'token' => $result['token'],
|
||
'expireIn' => $result['expireIn'],
|
||
'tokenType' => 'Bearer',
|
||
'planId' => $result['planId'],
|
||
'planName' => $result['planName'],
|
||
'companyId' => $result['companyId'],
|
||
];
|
||
return ResponseHelper::success($data, '换取成功');
|
||
}
|
||
}
|