PHP 从数组对象中取出数组提示:Undefined property: stdClass::$subject

是由于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;
        }

  

posted @ 2019-06-08 09:46  微联云  阅读(9393)  评论(0编辑  收藏  举报