作者 王智

文档修改

@@ -605,39 +605,7 @@ class Api @@ -605,39 +605,7 @@ class Api
605 //生成小程序码 605 //生成小程序码
606 public function InserMiniAppQrCode($Goods_id, $UserId, $Path) 606 public function InserMiniAppQrCode($Goods_id, $UserId, $Path)
607 { 607 {
608 - //小程序码  
609 - $options = [  
610 - 'app_id' => appid,  
611 - 'secret' => secret,  
612 - ];  
613 - $app = new Application($options);  
614 - // 获取 access token 实例  
615 - $accessToken = $app->access_token;  
616 - $AccessToken = $accessToken->getToken();  
617 - $url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $AccessToken;  
618 - $Json = [  
619 - 'scene' => 'Goods_id=' . $Goods_id . '&User_id=' . $UserId,  
620 - 'path' => $Path,  
621 -// 'is_hyaline' => True  
622 - ];  
623 - $MiniAppQrcodeVendor = $this->curlPost1($url, $Json);  
624 - $PayOrder = $this->PayOrder();  
625 - $path = './MiniAppQrCode/' . $PayOrder . '.png';  
626 - $res = file_put_contents($path, $MiniAppQrcodeVendor);//将微信返回的图片数据流写入文件  
627 - if ($res === false) {  
628 - $this->error('生成小程序码失败', 0);  
629 - die;  
630 - } else {  
631 - $MiniAppQrcodeUrl = $this->request->domain() . '/MiniAppQrCode/' . $PayOrder . '.png';  
632 - return $MiniAppQrcodeUrl;  
633 - }  
634 - }  
635 -  
636 -  
637 - //生成User小程序码  
638 - public function UserInserMiniAppQrCode($UserId, $Path)  
639 - {  
640 - //小程序码 608 +// //小程序码
641 // $options = [ 609 // $options = [
642 // 'app_id' => appid, 610 // 'app_id' => appid,
643 // 'secret' => secret, 611 // 'secret' => secret,
@@ -648,22 +616,54 @@ class Api @@ -648,22 +616,54 @@ class Api
648 // $AccessToken = $accessToken->getToken(); 616 // $AccessToken = $accessToken->getToken();
649 // $url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $AccessToken; 617 // $url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $AccessToken;
650 // $Json = [ 618 // $Json = [
651 -// 'scene' => 'Goods_id=0&User_id=' . $UserId, 619 +// 'scene' => 'Goods_id=' . $Goods_id . '&User_id=' . $UserId,
652 // 'path' => $Path, 620 // 'path' => $Path,
653 //// 'is_hyaline' => True 621 //// 'is_hyaline' => True
654 // ]; 622 // ];
655 // $MiniAppQrcodeVendor = $this->curlPost1($url, $Json); 623 // $MiniAppQrcodeVendor = $this->curlPost1($url, $Json);
656 -// $JsonDecode = json_decode($MiniAppQrcodeVendor, true); 624 +// $PayOrder = $this->PayOrder();
  625 +// $path = './MiniAppQrCode/' . $PayOrder . '.png';
657 $JsonDecode = json_decode('{"errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest rid: 604f8b86-35e79e71-2a52ba2d"}', true); 626 $JsonDecode = json_decode('{"errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest rid: 604f8b86-35e79e71-2a52ba2d"}', true);
658 if ($JsonDecode['errcode'] && $JsonDecode['errcode'] == 40001) { 627 if ($JsonDecode['errcode'] && $JsonDecode['errcode'] == 40001) {
659 $this->error('网咯拥堵'); 628 $this->error('网咯拥堵');
660 } 629 }
661 return 1; 630 return 1;
  631 + $res = file_put_contents($path, $MiniAppQrcodeVendor);//将微信返回的图片数据流写入文件
  632 + if ($res === false) {
  633 + $this->error('生成小程序码失败', 0);
  634 + die;
  635 + } else {
  636 + $MiniAppQrcodeUrl = $this->request->domain() . '/MiniAppQrCode/' . $PayOrder . '.png';
  637 + return $MiniAppQrcodeUrl;
  638 + }
  639 + }
  640 +
  641 +
  642 + //生成User小程序码
  643 + public function UserInserMiniAppQrCode($UserId, $Path)
  644 + {
  645 + //小程序码
  646 + $options = [
  647 + 'app_id' => appid,
  648 + 'secret' => secret,
  649 + ];
  650 + $app = new Application($options);
  651 + // 获取 access token 实例
  652 + $accessToken = $app->access_token;
  653 + $AccessToken = $accessToken->getToken();
  654 + $url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $AccessToken;
  655 + $Json = [
  656 + 'scene' => 'Goods_id=0&User_id=' . $UserId,
  657 + 'path' => $Path,
  658 +// 'is_hyaline' => True
  659 + ];
  660 + $MiniAppQrcodeVendor = $this->curlPost1($url, $Json);
662 $PayOrder = $this->PayOrder(); 661 $PayOrder = $this->PayOrder();
663 $path = './MiniAppQrCode/' . $UserId . '.png'; 662 $path = './MiniAppQrCode/' . $UserId . '.png';
664 $res = file_put_contents($path, $MiniAppQrcodeVendor);//将微信返回的图片数据流写入文件 663 $res = file_put_contents($path, $MiniAppQrcodeVendor);//将微信返回的图片数据流写入文件
665 if ($res === false) { 664 if ($res === false) {
666 $this->error('生成小程序码失败', 0); 665 $this->error('生成小程序码失败', 0);
  666 + die;
667 } else { 667 } else {
668 $MiniAppQrcodeUrl = $this->request->domain() . '/MiniAppQrCode/' . $UserId . '.png'; 668 $MiniAppQrcodeUrl = $this->request->domain() . '/MiniAppQrCode/' . $UserId . '.png';
669 return $MiniAppQrcodeUrl; 669 return $MiniAppQrcodeUrl;