是因为PHP增长严谨性,首先要加下判断数组值是否存在,而后在获取!
if (isset($result->access_token)) { html
}web
$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;
}