Files
cunkebao_v3/Server/application/common/controller/OpenAuthController.php
Manus AI 03ae8c07b6 feat: 同步本地全量开发到 GitHub(前端/后端/超管/开发文档规则)
含 AI 助手、抖音 OAuth、流量池推送、支付获客、SuperAdmin 设备与场景管理等本地迭代;以本地为准单向推送,未拉取远程。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-26 22:12:40 +08:00

51 lines
1.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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, '换取成功');
}
}