getAccessToken(); $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={$access_token}"; // 构建请求 $data = compact('scene', 'width'); !is_null($page) && $data['page'] = $page; // 返回结果 $result = $this->post($url, json_encode($data, JSON_UNESCAPED_UNICODE)); // 记录日志 log_write([ 'describe' => '获取小程序码', 'params' => $data, 'result' => strpos($result, 'errcode') ? $result : 'image' ]); if (strpos($result, 'errcode')) { $data = json_decode($result, true); throw new BaseException(['msg' => '小程序码获取失败 ' . $data['errmsg']]); } return $result; } }