是由于PHP增加严谨性,首先要加下判断数组值是否存在,然后在获取!
if (isset($result->access_token)) {
}
$curl = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$this->app_id.'&secret='.$this->app_secret.'&code='.$code.'&grant_type=authorization_code';$content = $this->_request($curl);$result = json_decode($content);//先判断是否有值,然后通过access_token和openid拉取用户信息if (isset($result->access_token)) {$webAccess_token = $result->access_token;$openid = $result->openid;}