cxgj/cxe/wechat/src/Wechat/Qrcode.php
2023-11-27 09:45:13 +08:00

50 lines
1.5 KiB
PHP

<?php
/**
* @author Any
* @description Do it yourself.
* @date 2018-6-21 21:47:19
* @version 1.0.0
*/
namespace Wechat;
class Qrcode extends Base
{
//发送请求获取小程序二维码
public function getWxappQrcode($accessToken,$body)
{
$url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={$accessToken}";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
if (!empty($body)) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
//发送请求获取小程序二维码-长期
public function getWxappQrcodeLong($accessToken,$body)
{
$url = "https://api.weixin.qq.com/wxa/getwxacode?access_token={$accessToken}";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
if (!empty($body)) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
}