public function getAccessToken()
{
$appid = '**************';
$secret = '*********';
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$appid."&secret=".$secret;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
$res = curl_exec($ch);
curl_close($ch);
return $res;
// exit();
}
哪里有错误吗?
php 写法没有啥问题,你这打印是前端请求后端数据返回的?去检查一下后端数据返回。