【发布时间】:2014-10-21 04:59:01
【问题描述】:
我需要将事件插入不属于我(其他用户)的多个日历。 它不必在一个命令中......
为了测试 Google 日历 API,我使用“插入”将新事件添加到我自己的日历中,并且效果很好:
// Create service from client
require_once "google-api-php-client-master/src/Google/Client.php";
require_once "google-api-php-client-master/src/Google/Service.php";
$client = new Google_Client();
$client->addScope("https://www.googleapis.com/auth/calendar");
$client->setAccessToken(htmlspecialchars_decode(get_access_token()));
$event = new Google_Service_Calendar_Event();
$event->setSummary($bean->name);
$event->setLocation($bean->location);
$event->setDescription($bean->description);
...
...
$service = new Google_Service_Calendar($client);
$createdEvent = $service->events->insert($user->google_cal_id_c, $event);
问题是,当我使用我的同事日历 ID(我从他的日历设置中获取)作为参数操作“插入”并尝试将事件插入他的日历时, 我收到“404 未找到”错误。
更新:
我注意到当同事与我共享他的日历时,我才可以插入事件。 这是否意味着我所有的 60 位同事都需要与我的(主要)共享他们的日历? 因为我真的不想这样! 我不能将事件添加到不与我共享他们的日历吗?
【问题讨论】:
-
您需要让您的同事验证您的应用程序,存储刷新令牌,然后您才能访问他们的日历。
-
哦,所以每个使用我的软件的用户都必须登录谷歌,通过身份验证过程,通过这个身份验证过程,我将为他获得一个访问令牌,我将用来更新他的日历?好的,会尝试并及时通知您,谢谢!
-
它不是 Google Calendar api,但它至少可以帮助您了解 oauth2 流程。 daimto.com/google-oauth2-php
-
是的,是的,我已经有了,只是不知道我想要插入的每个日历都需要访问令牌:),以为是每个项目....会让你随时发布。 . 再次感谢!
-
不是每个日历都是每个用户。如果用户有 10 个日历,一旦他们授予您访问权限,您将有权写入所有日历。
标签: php google-api google-calendar-api