Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 问题令牌在Google API上过期_Php_Google Api_Access Token - Fatal编程技术网

Php 问题令牌在Google API上过期

Php 问题令牌在Google API上过期,php,google-api,access-token,Php,Google Api,Access Token,大家早上好,使用google api client to PHP对用户进行身份验证,但有时会过期“acces token”并再次调用对用户进行身份验证,任何知道设置或修改文件以延长令牌使用时间的人都非常感谢您的帮助。我也遇到了同样的问题,我使用了一个名为isAccessTokenExpired()的方法,然后再次发出身份验证请求 if (isset($_SESSION['token'])) { googleClient->setAccessToken($_SESSION['to

大家早上好,使用google api client to PHP对用户进行身份验证,但有时会过期“acces token”并再次调用对用户进行身份验证,任何知道设置或修改文件以延长令牌使用时间的人都非常感谢您的帮助。

我也遇到了同样的问题,我使用了一个名为isAccessTokenExpired()的方法,然后再次发出身份验证请求

if (isset($_SESSION['token'])) {
      googleClient->setAccessToken($_SESSION['token']);
}

if (googleClient->isAccessTokenExpired()) {
    $authUrl = googleClient->createAuthUrl();
    header("Location:$authUrl");
}

希望有帮助:)。

您必须调用当前Google_客户端对象中的方法,对于我来说,在本例中是
googleClient=new Google_Client()