|
@@ -6,6 +6,8 @@ use app\common\controller\Api;
|
|
|
use Think\Cache;
|
|
|
use think\Db;
|
|
|
use wxpay;
|
|
|
+use Qcloud\Cos\Client;
|
|
|
+use Qcloud\Cos\Exception\ServiceResponseException;
|
|
|
|
|
|
|
|
|
* 首页接口
|
|
@@ -973,4 +975,102 @@ class Index extends Api
|
|
|
|
|
|
$this->success('分享链接', $rs['link']);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public function getqrcode() {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ $access_token = '';
|
|
|
+ if (!$access_token) {
|
|
|
+
|
|
|
+
|
|
|
+ $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx326ed0bf442d2773&secret=33609a3bc45bb407f0b26816158405b8';
|
|
|
+ $result = file_get_contents($url);
|
|
|
+ $result = json_decode($result, true);
|
|
|
+ $access_token = $result['access_token'];
|
|
|
+
|
|
|
+ Cache::set('access_token', $access_token, 7000);
|
|
|
+ }
|
|
|
+ if (!$access_token) {
|
|
|
+ $this->error('参数缺失');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $data['scene'] = 'id=AVwvR&code='.$this->auth->invite_no;
|
|
|
+
|
|
|
+ $data['page'] = 'pages/product/product';
|
|
|
+
|
|
|
+ $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" . $access_token;
|
|
|
+ $ch = curl_init($url);
|
|
|
+ $timeout = 6000;
|
|
|
+ curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
+ curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
|
+ curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
+ curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
|
|
|
+ curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
|
|
+ $ret = curl_exec($ch);
|
|
|
+ curl_close($ch);
|
|
|
+
|
|
|
+ if (is_array($ret)) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+
|
|
|
+ $secretId = "AKIDhDTSBdoTs0rS4bx3rQijSu61f3B2cv3y";
|
|
|
+ $secretKey = "f3A1btufAOL2SbT4ORDiwtZy7yYooY1D";
|
|
|
+ $region = "ap-beijing";
|
|
|
+ $cosClient = new Client(
|
|
|
+ array(
|
|
|
+ 'region' => $region,
|
|
|
+ 'schema' => 'https',
|
|
|
+ 'credentials'=> array(
|
|
|
+ 'secretId' => $secretId ,
|
|
|
+ 'secretKey' => $secretKey)));
|
|
|
+
|
|
|
+ $path = "qrcode/";
|
|
|
+ $fileName = time() . rand(10000,99999) . ".png";
|
|
|
+ $result = $cosClient->putObject(array(
|
|
|
+ 'Bucket' => 'examplebucket-1250000000',
|
|
|
+ 'Key' => $path . $fileName,
|
|
|
+ 'Body' => $ret,
|
|
|
+ ));
|
|
|
+
|
|
|
+ p($result);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|