{"errcode":41030,"errmsg":"invalid page rid: 691c357f-01e631e9-65b63f92"}
page参数是pages/index/index调用接口之后出现报错
appid wx9e901e5c85eb4e21
//生成二维码
public function code()
{
header('Content-Type: image/jpeg');
$id = 28;
$data = array();
$data['scene'] = 'id=' . $id; //自定义信息,可以填写诸如识别用户身份的字段,注意用中文时的情况
// $data['page'] = 'pages/code/index'; //扫描后对应的path
$data['page'] = 'pages/index/index'; //扫描后对应的path
// $data['width'] = 800;//自定义的尺寸
// $data['env_version'] = 'develop'; //开发版
$data['env_version'] = 'trial'; //试用版
$data['auto_color'] = false; //是否自定义颜色
$color = array(
'r' => '221',
'g' => '0',
'b' => '0',
);
$data['line_color'] = $color; //自定义的颜色值
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
$access_token = $this->get_access_token();
// var_dump($access_token);
$url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $access_token;
// echo $url . '<br>';
// echo $data . '<br>';
\ob_start();
echo http_request($url, $data);
// var_dump($qrdata);
$img = ob_get_contents();
ob_end_flush();
ob_end_clean();
header('Content-Type: text/html; charset=utf-8');
// $img = 'data:image/jpeg;base64,' . base64_encode($img);
return $img;
}
public function get_access_token()
{
$appid = $this->appId;
//小程序秘钥
$secret = $this->appSecret;
$data['grant_type'] = 'client_credential';
$data['appid'] = $appid;
$data['secret'] = $secret;
$url = 'https://api.weixin.qq.com/cgi-bin/stable_token';
$response = http_request($url, json_encode($data, JSON_UNESCAPED_UNICODE));
$rr = json_decode($response, true);
$access_token = $rr['access_token'];
// dump($access_token);
return $access_token;
}
/**
* 合并后的HTTP请求函数
* 功能说明:结合get_http_array和http_request函数的优点,提供完整的HTTP请求功能
*
* @param string $url 请求的URL地址
* @param mixed $data 可选,请求数据
* @param array $headers 可选,请求头数组
* @param bool $to_array 可选,是否将返回结果JSON解码为对象,默认false
* @return mixed 请求返回的数据,根据$to_array参数可能是字符串或JSON对象
*/
function http_request($url, $data = null, $headers = array(), $to_array = false)
{
$ci = curl_init();
// 设置URL
curl_setopt($ci, CURLOPT_URL, $url);
// 设置请求头
if (!empty($headers) && count($headers) >= 1) {
curl_setopt($ci, CURLOPT_HTTPHEADER, $headers);
}
// 设置SSL验证选项
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ci, CURLOPT_SSL_VERIFYHOST, false);
// 设置其他选项
curl_setopt($ci, CURLOPT_RETURNTRANSFER, true); //没有这个会自动输出,不用print_r();也会在后面多个1
curl_setopt($ci, CURLOPT_FOLLOWLOCATION, true); //跟随重定向
// 设置POST数据(如果有)
if (!empty($data)) {
curl_setopt($ci, CURLOPT_POST, 1);
curl_setopt($ci, CURLOPT_POSTFIELDS, $data);
}
// 执行请求
$output = curl_exec($ci);
// 关闭curl资源
curl_close($ci);
// 记录日志
Log::write('模版返回', print_r($output, true));
// 根据参数决定是否JSON解码
if ($to_array && !empty($output)) {
return json_decode($output, true);
}
return $output;
}

不用看代码,postman请求吧,正式版没有页面,就check_path改成false