繁体   English   中英

使用API​​从Google日历检索事件

[英]Retrieve Events from Google Calendar Using API

我是使用Google Calendar API和PHP的完全新手,我似乎无法弄清楚如何实现我想做的事情。 基本上,我想从带有Google日历的webapps098@gmail.com的Google日历中检索事件。 我当前的代码是这样的

require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_BooksService.php';
require_once 'google-api-php-client/src/contrib/Google_CalendarService.php';

$client = new Google_Client();
$client->setUseObjects(true);
$service = new Google_CalendarService($client);

try{
    $events = $service->calendars->get('webapps098@gmail.com');
    print_r($events);
}catch(Exception $e){
    echo $e;
    }

我收到错误:

异常“ Google_ServiceException”,消息为“在C:\\ xampp \\ htdocs \\ Test \\ google-中调用GET https://www.googleapis.com/calendar/v3/calendars/webapps098@gmail.com错误:(401)需要登录” api-php-client \\ src \\ io \\ Google_REST.php:66堆栈跟踪:#0 C:\\ xampp \\ htdocs \\ Test \\ google-api-php-client \\ src \\ io \\ Google_REST.php(36):Google_REST: :decodeHttpResponse(Object(Google_HttpRequest))#1 C:\\ xampp \\ htdocs \\ Test \\ google-api-php-client \\ src \\ service \\ Google_ServiceResource.php(186):Google_REST :: execute(Object(Google_HttpRequest))#2 C:\\ xampp \\ htdocs \\ Test \\ google-api-php-client \\ src \\ contrib \\ Google_CalendarService.php(300):Google_ServiceResource-> __ call('get',Array)#3 C:\\ xampp \\ htdocs \\ Test \\ refreshscript.php(10):Google_CalendarsServiceResource-> get('webapps098 @ gmai ...')#4 {main}

希望任何人都能帮忙! 抱歉,谢谢您的理解。

您正在尝试获取需要具有oAuth令牌的内容。 如果您只是从公共日历中提取事件,建议您使用Google供稿,而不要使用Google API。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM