首页 > 解决方案 > 使用带有 PHP 的 Google API 获取日历事件时出现 404 错误

问题描述

尝试通过 API 访问 Google 日历时,我在 PHP 中收到此错误:

消息:调用 GET https://www.googleapis.com/calendar/v3/calendars/CALENDARID/events?maxResults=10&orderBy=startTime&singleEvents=true&timeMin=2019-12-25T00%3A00%3A00-05%3A00&timeMax=2019-12 时出错-25T23%3A59%3A59-05%3A00&timeZone=America%2FNew_York&key=KEY : (404) 未找到

PHP:

require APPPATH . "third_party/google-api-php/src/Google/autoload.php";
$this->client = new Google_Client();
$this->client->setApplicationName('Google Calendar Api');
$this->client->setAuthConfigFile('<PATH TO JSON FILE>');
$this->client->setDeveloperKey('<DEVELOPERKEY>');
$this->client->setAccessType('offline');
$this->client->setApprovalPrompt('consent');
$this->client->setIncludeGrantedScopes(true);
$this->client->addScope(Google_Service_Calendar::CALENDAR);

PHP:

$results = $this->googlecalendar_model->calendar->events->listEvents($calendarId, $optParams);

关于 404 错误原因的任何想法?

标签: phpapicalendar

解决方案


推荐阅读