2017-09-01 110 views
0

我正在使用Google服务帐户在我的Web应用程序中实现Google日历API。Google Calendar API事件邀请不使用服务帐户身份验证发送到非Gmail帐户

据我研究了很多文件,但没有找到确切的解决方案。

我尝试以下操作:

1)使用 “的OAuth 2.0客户端ID” 证书。 - 我可以在Google日历中创建活动。 - 同时发送电子邮件通知给所有与会者(包括非Gmail账户)。 - 但缺点是它必须要求谷歌身份验证(谷歌登录)。 - 按照我的要求,任何人都可以在没有谷歌登录的情况下在谷歌日历活动中创建。

2)使用“服务帐户”凭据。 - 我可以在Google日历中创建活动。 - 仅在与会者中向Gmail地址发送电子邮件通知。 - 无需谷歌登录。

我更喜欢第二种方式。

$rule = new Google_Service_Calendar_AclRule(); 
$scope = new Google_Service_Calendar_AclRuleScope(); 

$scope->setType("user"); 
$scope->setValue("[email protected]"); 
$scope->setValue("[email protected]"); 
$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' => '[email protected]'), 
     array('email' => '[email protected]'), 
     array('email' => '[email protected]'), 
    ), 
    'reminders' => array(
     'useDefault' => FALSE, 
     'overrides' => array(
     array('method' => 'email', 'minutes' => 24 * 60), 
     array('method' => 'popup', 'minutes' => 10), 
    ), 
    ) 
)); 

$calendarId = '[email protected]'; 

$sendNotifications = array('sendNotifications' => true); 

$event_response = $calendar_service->events->insert($calendarId, $event_data, $sendNotifications); 

我唯一的问题是我无法事件通知发送到非Gmail帐户意味着电子邮件没有收到(hotmail.com,yopmail.com,等...)

请建议是有任何方式来解决这个问题。

感谢

+0

我已经从您的问题中删除了fullCalendar标记,因为问题中没有涉及到fullCalendar库。请不要使用与问题无关的标签。 – ADyson

+0

......“请建议有什么方法可以解决这个问题。”什么问题?你还没有提到问题,或任何错误消息,或任何其他事情。你刚刚展示了一些代码。标题中有一些内容,但它太模糊 - 应该在问题本身中提供适当的问题详细信息。 – ADyson

回答

0

我发现,这个问题是唯一的“yopmail.com”域。对于其他电子邮件域它工作正常。谷歌事件邀请正在处理谷歌通知标准和规范。

相关问题