下面是自己在项目中已经遇到的情况,随时添加
第一种情况:URL中包含空格
function httpGet($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 500);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
$res = curl_exec($curl);
curl_close($curl);
return $res;
}
$userUrl = " https://api.weixin.qq.com/cgi-bin/user/info?access_token={$accessToken}&openid={$id}&lang=zh_CN";
$userinfo = httpGet($userUrl);
//结果返回的false,$userUrl 开头有个空格(从别的地方复制过来的URL),通过别人的分享得到的答案
网友评论