function __construct($code){
$this->code = $code;
$this->wxAppID = config('wx.app_id');
$this->wxAppSecret = config('wx.app_secret');
$this->wxLoginUrl = sprintf(
config('wx.login_url'), $this->wxAppID, $this->wxAppSecret, $this->code);
}
public function get(){
$result = curl_get($this->wxLoginUrl);
$wxResult = json_decode($result,true);
if(empty($wxResult)){
throw new Exception('获取openID异常,微信内部错误');
}
else{
$loginFail = array_key_exists('errcode',$wxResult);
if($loginFail){
$this->processLoginError($wxResult);
}
else{
$this->grantToken($wxResult);
}
}
}
调试的时候,通过断点查看能够正确获取code和appid等参数。
$result = curl_get($this->wxLoginUrl)执行后返回false结果。
但是直接在浏览器输入带参数地址,能够正确返回结果。
求解。