作者 王智

文档修改

... ... @@ -605,39 +605,7 @@ class Api
//生成小程序码
public function InserMiniAppQrCode($Goods_id, $UserId, $Path)
{
//小程序码
$options = [
'app_id' => appid,
'secret' => secret,
];
$app = new Application($options);
// 获取 access token 实例
$accessToken = $app->access_token;
$AccessToken = $accessToken->getToken();
$url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $AccessToken;
$Json = [
'scene' => 'Goods_id=' . $Goods_id . '&User_id=' . $UserId,
'path' => $Path,
// 'is_hyaline' => True
];
$MiniAppQrcodeVendor = $this->curlPost1($url, $Json);
$PayOrder = $this->PayOrder();
$path = './MiniAppQrCode/' . $PayOrder . '.png';
$res = file_put_contents($path, $MiniAppQrcodeVendor);//将微信返回的图片数据流写入文件
if ($res === false) {
$this->error('生成小程序码失败', 0);
die;
} else {
$MiniAppQrcodeUrl = $this->request->domain() . '/MiniAppQrCode/' . $PayOrder . '.png';
return $MiniAppQrcodeUrl;
}
}
//生成User小程序码
public function UserInserMiniAppQrCode($UserId, $Path)
{
//小程序码
// //小程序码
// $options = [
// 'app_id' => appid,
// 'secret' => secret,
... ... @@ -648,22 +616,54 @@ class Api
// $AccessToken = $accessToken->getToken();
// $url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $AccessToken;
// $Json = [
// 'scene' => 'Goods_id=0&User_id=' . $UserId,
// 'scene' => 'Goods_id=' . $Goods_id . '&User_id=' . $UserId,
// 'path' => $Path,
//// 'is_hyaline' => True
// ];
// $MiniAppQrcodeVendor = $this->curlPost1($url, $Json);
// $JsonDecode = json_decode($MiniAppQrcodeVendor, true);
// $PayOrder = $this->PayOrder();
// $path = './MiniAppQrCode/' . $PayOrder . '.png';
$JsonDecode = json_decode('{"errcode":40001,"errmsg":"invalid credential, access_token is invalid or not latest rid: 604f8b86-35e79e71-2a52ba2d"}', true);
if ($JsonDecode['errcode'] && $JsonDecode['errcode'] == 40001) {
$this->error('网咯拥堵');
}
return 1;
$res = file_put_contents($path, $MiniAppQrcodeVendor);//将微信返回的图片数据流写入文件
if ($res === false) {
$this->error('生成小程序码失败', 0);
die;
} else {
$MiniAppQrcodeUrl = $this->request->domain() . '/MiniAppQrCode/' . $PayOrder . '.png';
return $MiniAppQrcodeUrl;
}
}
//生成User小程序码
public function UserInserMiniAppQrCode($UserId, $Path)
{
//小程序码
$options = [
'app_id' => appid,
'secret' => secret,
];
$app = new Application($options);
// 获取 access token 实例
$accessToken = $app->access_token;
$AccessToken = $accessToken->getToken();
$url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $AccessToken;
$Json = [
'scene' => 'Goods_id=0&User_id=' . $UserId,
'path' => $Path,
// 'is_hyaline' => True
];
$MiniAppQrcodeVendor = $this->curlPost1($url, $Json);
$PayOrder = $this->PayOrder();
$path = './MiniAppQrCode/' . $UserId . '.png';
$res = file_put_contents($path, $MiniAppQrcodeVendor);//将微信返回的图片数据流写入文件
if ($res === false) {
$this->error('生成小程序码失败', 0);
die;
} else {
$MiniAppQrcodeUrl = $this->request->domain() . '/MiniAppQrCode/' . $UserId . '.png';
return $MiniAppQrcodeUrl;
... ...