[英]Google Calendar API event invitation not sending to non-gmail account using Service Account authentication
我正在使用Google服务帐户将google calendar API实施到我的Web应用程序。
据我研究了大量文档,但没有找到确切的解决方案。
我尝试了以下操作:
1)使用“ OAuth 2.0客户端ID ”凭据。 -我可以在Google日历中创建活动。 -还将电子邮件通知发送给所有与会者(包括非Gmail帐户)。 -但缺点是它必须要求Google身份验证(google登录)。 -根据我的要求,任何人都可以在Google日历活动中创建Google而不登录。
2)使用“ 服务帐户 ”凭据。 -我可以在Google日历中创建活动。 -仅在参与者之间将电子邮件通知发送到gmail地址。 -无需Google登录。
我更喜欢第二种方式。
$rule = new Google_Service_Calendar_AclRule();
$scope = new Google_Service_Calendar_AclRuleScope();
$scope->setType("user");
$scope->setValue("xxx@gmail.com");
$scope->setValue("xxxxxxx@xxx.iam.gserviceaccount.com");
$rule->setScope($scope);
$rule->setRole("owner");
$client = new Google_Client();
$client->setApplicationName("Calendar Service");
$client->setAuthConfig('service_secrets.json');
$client->addScope(Google_Service_Calendar::CALENDAR);
$calendar_service = new Google_Service_Calendar($client);
$calendarList = $calendar_service->calendarList;
$event_data = new Google_Service_Calendar_Event(array(
'summary' => "Service Account Test Event",
'location' => 'Los Angeles',
'description' => 'This is extrieme test event',
'start' => array(
'dateTime' => '2017-09-13T09:00:00-07:00',
'timeZone' => 'America/Los_Angeles',
),
'end' => array(
'dateTime' => '2017-09-13T17:00:00-07:00',
'timeZone' => 'America/Los_Angeles',
),
'recurrence' => array(
'RRULE:FREQ=DAILY;COUNT=2'
),
'attendees' => array(
array('email' => 'xxx@yopmail.com'),
array('email' => 'xxx@gmail.com'),
array('email' => 'xxx@hotmail.com'),
),
'reminders' => array(
'useDefault' => FALSE,
'overrides' => array(
array('method' => 'email', 'minutes' => 24 * 60),
array('method' => 'popup', 'minutes' => 10),
),
)
));
$calendarId = 'dsfsdfasdfxxxxxxxxxxxxxx@group.calendar.google.com';
$sendNotifications = array('sendNotifications' => true);
$event_response = $calendar_service->events->insert($calendarId, $event_data, $sendNotifications);
我唯一的问题是我无法向非Gmail帐户发送事件通知,这意味着未通过(hotmail.com,yopmail.com等)接收电子邮件
请建议有什么方法可以解决此问题。
谢谢
我发现问题出在唯一的“ yopmail.com”域。 对于其他电子邮件域,它可以正常工作。 Google事件邀请正在研究Google通知标准和规范。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.