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 生成小程序二维码
最新推荐文章于 2025-05-15 09:49:50 发布
本文介绍了一种通过PHP脚本获取微信小程序码的方法。利用微信开放平台API,通过发送POST请求并提供必要的参数来获取特定路径的小程序码。该过程包括获取访问令牌、构造请求数据、发起请求及处理响应。
1134

被折叠的 条评论
为什么被折叠?



