Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.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_Google Calendar Api - Fatal编程技术网

Php 存储代码或访问令牌的Google日历API

Php 存储代码或访问令牌的Google日历API,php,google-api,google-calendar-api,Php,Google Api,Google Calendar Api,我试图弄清楚谷歌日历,但我搞不清楚当我需要推送或获取数据时,我需要在数据库中存储哪个字符串来获取访问令牌 我向谷歌提出请求,他们返回: ?code=4/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx# 然后我验证: $client->authenticate($_GET['code']); 然后我得到访问令牌: $client->getAccessToken() 本次会议一切顺利。但是,我不想每次都要求用户进行身份验证。我是否可以存储$_G

我试图弄清楚谷歌日历,但我搞不清楚当我需要推送或获取数据时,我需要在数据库中存储哪个字符串来获取访问令牌

我向谷歌提出请求,他们返回:

?code=4/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx#
然后我验证:

$client->authenticate($_GET['code']);
然后我得到访问令牌:

$client->getAccessToken()
本次会议一切顺利。但是,我不想每次都要求用户进行身份验证。我是否可以存储$_GET['code']字符串,然后请求访问令牌,而无需用户每次进行身份验证


谢谢。

是的,这是绝对可能的

您需要阅读OAuth 2.0中有关Web服务器应用程序的内容。这将防止应用程序中的用户每次都在同意屏幕上提示进行授权

要使用“脱机访问”,您需要将以下代码段应用于您的应用程序:

$client->setAccessType("offline");
您可能还想通过以下链接了解更多关于OAuth 2.0的信息:

希望对你有帮助,祝你好运