12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- declare (strict_types = 1);
- namespace app\api\controller;
- use app\common\service\MpWxService;
- use app\store\model\analysis\AnalysisDailyVisit;
- /**
- * 微信小程序
- * @package app\api\controller
- */
- class MpWeiXin extends Controller
- {
- //小程序分享图
- public function qrCode(){
- $path = $this->request->get('path');
- $path = $path ? html_entity_decode($path) : '';
- $weixinToken = MpWxService::weixinTokenCache();
- $accessToken = $weixinToken['access_token'];
- $url = "https://api.weixin.qq.com/wxa/getwxacode?access_token=".$accessToken;
- if(empty($path)){
- $path = 'pages/tabBar/index/index';
- }
- $params["path"] = $path;
- $params['is_hyaline'] = true;//是否需要透明底色,为 true 时,生成透明底色的小程序码
- $params['width'] = 600;//二维码的宽度,单位 px。最小 280px,最大 1280px ,默认430
- $serve_env = env('SERVE_ENV');
- $env_version = $serve_env == 'test' ? 'trial' : 'release'; // 要打开的小程序版本,正式版:release,体验版:trial,开发版:develop
- $params['env_version'] = $env_version;
- $ret = curl_post($url,json_encode($params));
- $arr = json_decode($ret);
- if(isset($arr->errcode)&&$arr->errcode==40001){
- MpWxService::delweixinTokenCache();
- }
- ob_clean();
- return response($ret,200, ['content-type' => 'image/png']);
- }
- public function visit()
- {
- $weixinToken = MpWxService::weixinTokenCache();
- $accessToken = $weixinToken['access_token'];
- $url = "https://api.weixin.qq.com/datacube/getweanalysisappiddailyvisittrend?access_token=".$accessToken;
- // $url = "https://api.weixin.qq.com/datacube/getweanalysisappiddailyretaininfo?access_token=".$accessToken;
- // $url = "https://api.weixin.qq.com/datacube/getweanalysisappidvisitpage?access_token=".$accessToken;
- // $url = "https://api.weixin.qq.com/datacube/getweanalysisappiddailysummarytrend?access_token=".$accessToken;
- $params['begin_date'] = '20220323';
- $params['end_date'] = '20220323';
- $ret = curl_post($url,json_encode($params));
- $arr = json_decode($ret);
- if(isset($arr->errcode)&&$arr->errcode==40001){
- MpWxService::delweixinTokenCache();
- }
- dd($arr);
- }
- public function dailyVisit()
- {
- $res = AnalysisDailyVisit::addDailyInitVisit();
- dd($res);
- }
- }
|