Php 使用laravel和artdarek在Google Oauth上请求资源失败

Php 使用laravel和artdarek在Google Oauth上请求资源失败,php,laravel,oauth,google-api,single-sign-on,Php,Laravel,Oauth,Google Api,Single Sign On,我在网上搜索了他的问题的解决方案,但还没有找到解决办法。我需要帮助 我得到这个错误: OAuth\Common\Http\Exception\TokenResponseException 无法请求资源 下面是我的代码,如果我做错了什么,请帮我找出它。。。我已尝试手动使用重定向URL,但仍然出现相同的错误 public function loginWithGoogle() { $code= Input::get('code'); $googleService = OAuth:

我在网上搜索了他的问题的解决方案,但还没有找到解决办法。我需要帮助

我得到这个错误: OAuth\Common\Http\Exception\TokenResponseException 无法请求资源

下面是我的代码,如果我做错了什么,请帮我找出它。。。我已尝试手动使用重定向URL,但仍然出现相同的错误

public function loginWithGoogle()
{

    $code= Input::get('code'); 

    $googleService = OAuth::consumer('Google');

    if (!empty($code)){

        $token= $googleService->requestAccessToken($code);
        $result= json_decode($googleService->request('https://www.googleapis.com/oauth2/v1/userinfo' ), true);
             if(!empty($result){
                var_dump($result);
             }

    } else {
            // get googleService authorization
            $url = $googleService->getAuthorizationUri();

            // return to google login url
            return Redirect::to( (string)$url );
        }
} 

$token$level之前=错误报告(0);$result之后,错误报告($level);在if conditionUser中尝试这样做,我不明白你的意思。。你的意思是如果(!empty($code)){$level=error_reporting(0);$token=$googleService->requestAccessToken($code);$level=error_reporting($level);$result=json_decode($googleService->request(“”),true);您希望避免页面中出现错误,请在if条件下按照上述代码操作。请参考此链接用户,我正在使用artdarek,它已经解决了这一问题。它包含在错误消息中。在$token$level=error_reporting(0)之前,$result之后,error_reporting($level);在if conditionUser中尝试这样做,我不明白你的意思..你是说if(!empty($code)){$level=error_reporting(0);$token=$googleService->requestAccessToken($code);$level=error_reporting($level);$result=json_decode($googleService->request(“”),true);您想避免页面中出现错误,请在if条件下遵循上述代码。请参考此链接用户,我正在使用artdarek,它已经解决了这一问题。它包含在错误消息中,我正在查看。