2017-09-01 69 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」域。對於其他電子郵件域它工作正常。谷歌事件邀請正在處理谷歌通知標準和規範。

相關問題