【发布时间】:2023-03-07 20:54:01
【问题描述】:
我是一名初级程序员,也是谷歌日历 API 的新手。 我想使用谷歌提供的代码创建一个事件来创建一个事件,问题是我只能获取我即将发生的事件的列表,但我无法创建一个事件。
此代码有效:https://developers.google.com/calendar/quickstart/php
我把这段代码放在另一个下面:
$event = new Google_Service_Calendar_Event(array(
'summary' => 'Google I/O 2015',
'location' => '800 Howard St., San Francisco, CA 94103',
'description' => 'A chance to hear more about Google\'s developer products.',
'start' => array(
'dateTime' => '2018-08-28T09:00:00-07:00',
'timeZone' => 'Europe/Brussels',
),
'end' => array(
'dateTime' => '2018-08-28T17:00:00-07:00',
'timeZone' => 'Europe/Brussels',
),
'recurrence' => array(
'RRULE:FREQ=DAILY;COUNT=2'
),
'attendees' => array(
array('email' => 'stefanos.stoikos@gmail.com'),
array('email' => 'stefanos.stoikos@gmail.com'),
),
'reminders' => array(
'useDefault' => FALSE,
'overrides' => array(
array('method' => 'email', 'minutes' => 24 * 60),
array('method' => 'popup', 'minutes' => 10),
),
),
));
$calendarId = 'primary';
$event = $service->events->insert($calendarId, $event);
printf('Event created: %s\n', $event->htmlLink);
当我在 cmd 中执行此操作时,出现以下错误:
Fatal error: Uncaught exception 'Google_Service_Exception' with message '{
"error": {
"errors": [
{
"domain": "global",
"reason": "insufficientPermissions",
"message": "Insufficient Permission"
}
],
"code": 403,
"message": "Insufficient Permission"
}
}
' in C:\xampp\htdocs\StefanosProject\vendor\google\apiclient\src\Google\Http\REST.php:118
Stack trace:
#0 C:\xampp\htdocs\StefanosProject\vendor\google\apiclient\src\Google\Http\REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...')
#1 [internal function]: Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...')
#2 C:\xampp\htdocs\StefanosProject\vendor\google\apiclient\src\Google\Task\Runner.php(176): call_user_func_array(Array, Array)
#3 C:\xampp\htdocs\StefanosProject\vendor\google\apiclient\src\Google\Http\REST.php(58): Google_Task_Runner->run()
#4 C:\xampp\htdocs\StefanosProject\vendor\google\apiclient\src in C:\xampp\htdocs\StefanosProject\vendor\google\apiclient\src\Google\Http\REST.php on line 118
我尝试了不同的解决方案来创建一个事件,但我一直有错误,有人可以帮我吗?
【问题讨论】:
标签: php cmd google-calendar-api