|
@@ -18,6 +18,48 @@ class Index extends Api
|
|
|
$this->success();
|
|
|
}
|
|
|
|
|
|
+ public function mini_code()
|
|
|
+ {
|
|
|
+ $scene = 'kongjianyuyue';
|
|
|
+ $page_url = '/pages/active/reserve';
|
|
|
+
|
|
|
+ $value = config('wxMiniProgram');
|
|
|
+ $appid = $value['appid'];
|
|
|
+ $secret = $value['secret'];
|
|
|
+ $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' . $appid . '&secret=' . $secret;
|
|
|
+ $res = file_get_contents($url);
|
|
|
+
|
|
|
+ $token = json_decode($res, true)['access_token'];
|
|
|
+ $URL = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $token;
|
|
|
+ $data = [
|
|
|
+
|
|
|
+ 'page' => $page_url,
|
|
|
+ 'env_version' => 'trial',
|
|
|
+ 'width' => 280,
|
|
|
+ 'auto_color' => false,
|
|
|
+ 'is_hyaline' => false,
|
|
|
+ 'check_path' => false,
|
|
|
+ ];
|
|
|
+ $json = json_encode($data);
|
|
|
+
|
|
|
+ $result = curl_post($URL,$json);
|
|
|
+
|
|
|
+ $path = ROOT_PATH . 'public/uploads/minicode';
|
|
|
+ $path2 = '/uploads/minicode';
|
|
|
+
|
|
|
+ if (!file_exists($path)) {
|
|
|
+ mkdir($path, 0777, true);
|
|
|
+ }
|
|
|
+ $path = $path . '/' . $scene . '.png';
|
|
|
+ $path2 = $path2 . '/' . $scene . '.png';
|
|
|
+
|
|
|
+ file_put_contents($path, $result);
|
|
|
+ dump($path2);
|
|
|
+ dump(httpurllocal($path2));
|
|
|
+
|
|
|
+ echo '<html><body><img src="'.httpurllocal($path2).'"></body></html>';
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* 首页
|
|
|
*/
|