【问题标题】:Retrieve Events from Google Calendar Using API使用 API 从 Google 日历中检索事件
【发布时间】:2014-04-22 17:29:03
【问题描述】:

我是 Google Calendar API 和 PHP 的新手,我似乎不知道如何实现我想做的事情。基本上,我想从带有 webapps098@gmail.com 的 calendarID 的谷歌日历中检索事件。 我当前的代码类似于

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”和消息“调用 GET 时出错” https://www.googleapis.com/calendar/v3/calendars/webapps098@gmail.com: (401) 需要登录 C:\xampp\htdocs\Test\google-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}

我希望任何人都可以提供帮助!抱歉,感谢您的理解。

【问题讨论】:

    标签: php calendar google-calendar-api


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-14
      相关资源
      最近更新 更多