错误信息:{"errcode":41001,"errmsg":"access_token missing"}
<?php
//发送POST请求
$url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=";
$access_token = "bz6LKNCiQN5fHDZNJwWbCiPXqRkrlkBUcBGwb3MlM-tmnXK6TGsHGbsETwcOXmezlIouHdD7Rv3g9aLicuF-gA";
$url = $url . urlencode($access_token);
echo "请求url:" . $url ."<br>";
//要请求的内容
$data['action_name'] = "QR_LIMIT_SCENE";
$scene['scene_id'] = 10;
$action_info['scene'] = $scene;
$data['action_info'] = $action_info;
$data = json_encode($data);
echo "请求参数:" . $data ."<br>";
//url
$url_info = parse_url($url);
var_dump($url_info);
echo "<br>";
if(!isset($url_info['port']))
{
$url_info['port'] = 80;
//模拟http请求头
$request .= "POST ".$url_info['path']." HTTP/1.1n";
$request .= "Host: ".$url_info['host']."n";
$request .= "Content-type: application/x-www-form-urlencodedn";
$request .= "Content-length: ".strlen($data)."n";
$request .= "Connection: closen";
$request .= "n";
$request .= $data."n";
}
$fp = fsockopen($url_info["host"], $url_info["port"]);
fputs($fp, $request);//把HTTP头发送出去
$inheader = 1;
while(!feof($fp))
{
//$result 是提交后返回的数据
$result .= fgets($fp, 1024);
}
echo $result;
fclose($fp);
?>
------解决方案--------------------
41001 缺少access_token参数
返回码说明
------解决方案--------------------
$fp = fsockopen($url_info["host"], $url_info["port"]);
和
$request .= "POST ".$url_info['path']." HTTP/1.1n";
$request .= "Host: ".$url_info['host']."n";
$request .= "Content-type: application/x-www-form-urlencodedn";
$request .= "Content-length: ".strlen($data)."n";
$request .= "Connection: closen";
$request .= "n";
$request .= $data."n";
里没有发现有token的信息。
------解决方案--------------------
$request .= "POST ".$url_info['path']." HTTP/1.1n";
这里填写带路径和参数的目标页名称,比如
/cgi-bin/qrcode/create?access_token=?????
无论是 get 还是 post 方式,都是这样写
友情提示:垃圾评论一律封号 加我微信:826096331拉你进VIP群学习群