每当我尝试将事件从myservice帐户移动到我的常规帐户时,问题就会出现 不是FOUNND,一切都很好,事件ID,日历ID,目标ID,它甚至从谷歌界面Google Move移动,但从代码中它说找不到,我试图在插入事件后移动(最后一行)
require 'src/Google/autoload.php';
require_once 'src/Google/Client.php';
require_once 'src/Google/Service/Calendar.php';
$Email_address = 'stafftesting@stafftesting-1204.iam.gserviceaccount.com';
$key_file_location = 'stafftesting-546f9e1a6522.p12';
$client = new Google_Client();
$client->setApplicationName("Google Calendar API PHP Quickstart");
$key = file_get_contents($key_file_location);
$scopes = "https://www.googleapis.com/auth/calendar";
$cred = new Google_Auth_AssertionCredentials(
$Email_address, array($scopes), $key);
$client->setAssertionCredentials($cred);
if ($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion($cred);
}
$service = new Google_Service_Calendar($client);
$event = new Google_Service_Calendar_Event(array(
'summary' => 'Sushildai Event',
'location' => '800 Howard St., San Francisco, CA 94103',
'start' => array(
'dateTime' => '2016-01-30T09:00:00-07:00',
'timeZone' => 'America/Los_Angeles', ),
'end' => array(
'dateTime' => '2016-01-30T11:00:00-07:00',
'timeZone' => 'America/Los_Angeles',
),
'attendees' => array(
array('email' => 'lpage@unifun.com'),
array('email' => 'sbrin@unifun.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);
$result = $service->events->move('primary',$event->id,'soorazk@gmail.com');
printf('Event created: %sn', $event->htmlLink);
$service->events->move('primary',$event->id, 'soorazkun1@gmail.com');
根据 Google 官方文档,"4*04 未找到"* 在几种情况下会发生。以下是一些示例:* 当请求的资源(具有提供的 ID)从未存在时。* 访问用户无法访问的日历时。
遇到"404 未找到"错误消息时,建议的操作是使用"指数退避"。Google Drive API 文档很好地解释了指数退避以及如何将其与 Google API 一起使用。指数退避是网络应用程序的标准错误处理策略,其中客户端在不断增加的时间内定期重试失败的请求。
这里有一个有用的谷歌文档,关于处理API错误和如何实现指数退避:https://developers.google.com/google-apps/calendar/v3/errors