Google日历如何解决“您需要让作者访问此日历”吗?

问题描述 投票:0回答:1

我正在尝试访问和编写我的虚拟日历,使网站的新功能,但有些东西阻止我改变我的虚拟日历。

到目前为止,当我尝试使用此代码时:

qazxsw poi 结果类似于Google Calendar API浏览。

我的日历API

$event = $calendar->calendars->get([email protected]);

该消息总是会说“您需要让作者访问此日历”。即使我已经通过权限$calendarId2 = '[email protected]'; $jobname = "Tesla"; $joblocation = "USA"; $jobdescription = "Interview with Elon Musk."; $startofjob = "2019-03-29T10:00:00.000+00:00"; $endofjob = "2019-03-30T18:00:00.000+00:00"; try { $client = GetGoogleClient(); $calendar = new \Google_Service_Calendar($client); $event = new \Google_Service_Calendar_Event(array( 'summary' => $jobname, 'location' => $joblocation, 'description' => $jobdescription, 'end' => array( 'dateTime' => $endofjob, 'timeZone' => 'Asia/Manila', ), 'start' => array( 'dateTime' => $startofjob, 'timeZone' => 'Asia/Manila', ), )); $event = $calendar->events->insert($calendarId2, $event); } catch(\Exception $e) { return ["error" => $e->getMessage()]; } Make changes to events将日历共享到服务帐户

附加信息

Make changes and manage sharing
php google-calendar-api slim
1个回答
0
投票

“你需要让作家访问这个日历。”

您可能已将其与服务帐户共享,但是您是否授予其写入权限?或只是阅读访问?我认为你应该仔细检查这通常是问题的原因。请记住,这只会让它访问这一个日历。

function GetGoogleClient(){ $client = new Google_Client(); //$client->setAuthConfig($credentialsFile); $client->addScope("https://www.googleapis.com/auth/drive", Google_Service_Sheets::SPREADSHEETS); $client->addScope("https://www.googleapis.com/auth/calendar"); //$client->addScope("https://www.googleapis.com/auth/calendar.events"); //same error result event with or without $client->setAuthConfig(CONST_GOOGLE_SERVICE_ACCOUNT_KEY); $client->setSubject(CONST_GOOGLE_SERVICE_ACCOUNT_EMAIL); $client->useApplicationDefaultCredentials(); return $client; }

此外,我认为你应该检查你的范围只是使用

enter image description here

我认为他们互相辱骂。退后一步确保日历工作,然后添加您的驱动器的东西

© www.soinside.com 2019 - 2024. All rights reserved.