mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
修改公众平台开放平台
This commit is contained in:
parent
cbe09a951b
commit
896680ac4f
@ -62,15 +62,15 @@ class Client extends Controller
|
|||||||
private function instance()
|
private function instance()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$code = $this->app->request->get('code', '');
|
$data = json_decode(debase64url(input('token', '')), true);
|
||||||
$data = json_decode(debase64url($code), true);
|
list($class, $appid, $time, $nostr, $sign) = [$data['class'], $data['appid'], $data['time'], $data['nostr'], $data['sign']];
|
||||||
list($class, $appid, $time, $sign) = [$data['class'], $data['appid'], $data['time'], $data['sign']];
|
$wechat = $this->app->db->name('WechatServiceConfig')->where(['authorizer_appid' => $appid])->find();
|
||||||
$config = $this->app->db->name('WechatServiceConfig')->where(['authorizer_appid' => $appid])->find();
|
if (empty($wechat)) throw new Exception("抱歉,该公众号{$appid}未授权!");
|
||||||
if (empty($config)) throw new Exception("抱歉,该公众号{$appid}未授权!");
|
if (abs(time() - $data['time']) > 10) throw new Exception('抱歉,接口调用时差过大!');
|
||||||
if (md5("{$class}#{$appid}#{$config['appkey']}#{$time}") !== $sign) {
|
if (md5("{$class}#{$appid}#{$wechat['appkey']}#{$time}#{$nostr}") !== $sign) {
|
||||||
throw new Exception("抱歉,该公众号{$appid}签名异常!");
|
throw new Exception("抱歉,该公众号{$appid}签名异常!");
|
||||||
}
|
}
|
||||||
return WechatService::$class($appid);
|
return WechatService::__callStatic($class, [$appid]);
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
return new \Exception($exception->getMessage(), $exception->getCode());
|
return new \Exception($exception->getMessage(), $exception->getCode());
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,8 @@ class ClientService extends WechatService
|
|||||||
throw new \think\Exception('请按顺序传入APPID及APPKEY两个参数!');
|
throw new \think\Exception('请按顺序传入APPID及APPKEY两个参数!');
|
||||||
}
|
}
|
||||||
list($appid, $appkey) = $arguments;
|
list($appid, $appkey) = $arguments;
|
||||||
$data = ['class' => $name, 'appid' => $appid, 'time' => time()];
|
$data = ['class' => $name, 'appid' => $appid, 'time' => time(), 'nostr' => uniqid()];
|
||||||
$data['sign'] = md5("{$data['class']}#{$appid}#{$appkey}#{$data['time']}");
|
$data['sign'] = md5("{$data['class']}#{$appid}#{$appkey}#{$data['time']}#{$data['nostr']}");
|
||||||
$code = enbase64url(json_encode($data, JSON_UNESCAPED_UNICODE));
|
$code = enbase64url(json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||||
if (class_exists('Yar_Client')) {
|
if (class_exists('Yar_Client')) {
|
||||||
$url = "http://127.0.0.1:1231/service/api.client/yar?not_init_session=1&code={$code}";
|
$url = "http://127.0.0.1:1231/service/api.client/yar?not_init_session=1&code={$code}";
|
||||||
|
@ -76,19 +76,19 @@
|
|||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<span class="color-green font-w7">微信消息与事件接收</span>
|
<span class="color-green font-w7">微信消息与事件接收</span>
|
||||||
<label class="relative block">
|
<label class="relative block">
|
||||||
<input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.push/notify/\$APPID\$',[],false,true)}">
|
<input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.push/notify/appid/\$APPID\$',[],false,true)}">
|
||||||
<a data-copy="{:url('@service/api.push/notify/\$APPID\$',[],false,true)}" class="fa fa-copy input-right-icon"></a>
|
<a data-copy="{:url('@service/api.push/notify/appid/\$APPID\$',[],false,true)}" class="fa fa-copy input-right-icon"></a>
|
||||||
</label>
|
</label>
|
||||||
<p class="help-block">通过该 URL 接收微信消息和事件推送,$APPID$ 将被替换为微信 AppId</p>
|
<p class="help-block">通过该 URL 接收微信消息和事件推送,$APPID$ 将被替换为微信 AppId</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<p class="color-green font-w7">客户端系统 Yar 模块接口</p>
|
<p class="color-green font-w7">客户端系统 Yar 模块接口</p>
|
||||||
<label class="relative block"><input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.client/yar/PARAM',[],false,true)}"></label>
|
<label class="relative block"><input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.client/yar',[],false,true)}?token=TOKEN"></label>
|
||||||
<p class="help-block">客户端 Yar 接口,PARAM 规则 AppName-AppId-AppKey-AppType</p>
|
<p class="help-block">客户端 Yar 接口,PARAM 规则 AppName-AppId-AppKey-AppType</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<p class="color-green font-w7">客户端系统 Soap 模块接口</p>
|
<p class="color-green font-w7">客户端系统 Soap 模块接口</p>
|
||||||
<label class="relative block"><input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.client/soap/PARAM',[],false,true)}"></label>
|
<label class="relative block"><input disabled class="layui-input layui-bg-gray" value="{:url('@service/api.client/soap',[],false,true)}?token=TOKEN"></label>
|
||||||
<p class="help-block">客户端 Soap 接口,PARAM 规则 AppName-AppId-AppKey-AppType</p>
|
<p class="help-block">客户端 Soap 接口,PARAM 规则 AppName-AppId-AppKey-AppType</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user