import("Vendor.Wxpay.lib.WxPay#Config", "", ".php");
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".\WxPayConfig::APPID."&secret=".\WxPayConfig::APPSECRET;
$ret = file_get_contents($url);
$access_token = json_decode($ret)->access_token;
$postData = array('path' => 'pages/member/login/login');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.weixin.qq.com/wxa/getwxacode?access_token=' . $access_token);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 500);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
$exec = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if (empty($error)) {
header("Content-type:application/octet-stream");
header("Accept-Ranges:bytes");
header("Accept-Length:" . strlen($exec));
header("Content-Disposition:attachment;filename=test.jpg" );
echo $exec;
}
php 生成小程序二維碼
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.