Wechat.php
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace app\api\controller;
use EasyWeChat\Factory;
/**
* 微信相关
* @package app\api\controller
*/
class Wechat extends BaseApi
{
protected $noNeedLogin = '';
protected $noNeedRight = '*';
/**
* jssdk 配置信息
* @ApiWeigh (23)
* @ApiTitle (jssdk配置信息)
* @ApiSummary (jssdk配置信息)
* @ApiMethod (POST)
* @ApiRoute (/api/wechat/wechat_jssdk)
* @ApiParams (name="url", type="string", required=true, description="当前地址")
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
* @ApiReturn ({
'code':'1',
'msg':'返回成功',
"data": {
"jssdk": {
"debug": false,
"beta": false,
"jsApiList": [
"updateAppMessageShareData",
"updateTimelineShareData"
],
"appId": "wxa9281176eb57c2f1",
"nonceStr": "YRPUWx9AaB",
"timestamp": 1597023466,
"url": "http://tangyuanji.t.brotop.cn/",
"signature": "ce924ae62e9cbc7917cee79dafd9d67d31400fcf"
}
}
})
*/
public function wechat_jssdk()
{
$url = $this->request->param('url','');
if(!$url) {
$this->error('参数错误');
}
$options = get_addon_config('third')['wechat'];
$options['secret'] = $options['app_secret'];
$app = Factory::officialAccount($options);
// 微信jssdk
$jssdk = $app->jssdk;
$jssdk->setUrl($url);
$data = json_decode($jssdk->buildConfig(config('option.apis'), $debug = false, $beta = false, $json = true),true);
unset($data['beta']);
unset($data['url']);
$return = [
'jssdk' => $data
];
$this->success('成功', $return);
}
}