1

Microsoft Graph API를 사용하여 Outlook의 일정 이벤트를 동기화하려고합니다. 나는 내 요청에 odata.track-changes 헤더를 추가하고 내가 마지막 요청 이후에 업데이트되었거나 생성 된 이벤트 만 가져 오기 위해 나중에 요청에 사용할 수있는 deltaToken을 수신 할 것이라고 제안한 Outlook API에 관한 this article을보고있었습니다. .캘린더 이벤트를 Microsoft Graph API와 동기화 할 수 있습니까?

나는 성공적으로 가져 오는 사건이었다,하지만 난 다시 deltaToken을받지 못했습니다 :/

이 단지 아웃룩 API에서 지원됩니까? 그래프의 응답은 Preference-Applied: odata.track-changes이므로 내 머리글을 인정합니다.

GET /v1.0/me/calendar/calendarView 
    ?startDateTime=2016-09-01T00:00:00.0000000 
    &endDateTime=2099-01-01T00:00:00.0000000 
    HTTP/1.1 
Host: graph.microsoft.com 
Authorization: Bearer XXX 
Prefer: odata.track-changes 
Prefer: odata.maxpagesize=3 //for testing 
Cache-Control: no-cache 

그리고 내 샘플 응답 : 나는 비록 약간 민감 할 수있는 아무것도 편집 됨

{ 
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('')/calendar/calendarView", 
    "value": [ 
    { 
     "@odata.etag": "", 
     "id": "", 
     "createdDateTime": "2016-08-04T14:00:25.8552351Z", 
     "lastModifiedDateTime": "2016-08-25T14:43:54.9950828Z", 
     "changeKey": "", 
     "categories": [ 
     "Orange category" 
     ], 
     "originalStartTimeZone": "Eastern Standard Time", 
     "originalEndTimeZone": "Eastern Standard Time", 
     "responseStatus": { 
     "response": "organizer", 
     "time": "0001-01-01T00:00:00Z" 
     }, 
     "iCalUId": "", 
     "reminderMinutesBeforeStart": 15, 
     "isReminderOn": true, 
     "hasAttachments": false, 
     "subject": "Closing on House", 
     "body": { 
     "contentType": "html", 
     "content": "" 
     }, 
     "bodyPreview": "", 
     "importance": "normal", 
     "sensitivity": "normal", 
     "start": { 
     "dateTime": "2016-09-08T19:30:00.0000000", 
     "timeZone": "UTC" 
     }, 
     "end": { 
     "dateTime": "2016-09-08T21:30:00.0000000", 
     "timeZone": "UTC" 
     }, 
     "location": { 
     "displayName": "245 E Main St", 
     "address": { 
      "street": "245 E Main St", 
      "city": "Somewhere", 
      "state": "NY", 
      "countryOrRegion": "United States", 
      "postalCode": "" 
     } 
     }, 
     "isAllDay": false, 
     "isCancelled": false, 
     "isOrganizer": true, 
     "recurrence": null, 
     "responseRequested": true, 
     "seriesMasterId": null, 
     "showAs": "busy", 
     "type": "singleInstance", 
     "attendees": [], 
     "organizer": { 
     "emailAddress": { 
      "name": "", 
      "address": "" 
     } 
     }, 
     "webLink": "https://outlook.office365.com/owa/?ItemID=" 
    }, 
    { 
     "@odata.etag": "", 
     "id": "", 
     "createdDateTime": "2016-08-19T18:02:39.0607411Z", 
     "lastModifiedDateTime": "2016-08-19T18:04:10.548447Z", 
     "changeKey": "", 
     "categories": [ 
     "Green category" 
     ], 
     "originalStartTimeZone": "UTC", 
     "originalEndTimeZone": "UTC", 
     "responseStatus": { 
     "response": "organizer", 
     "time": "0001-01-01T00:00:00Z" 
     }, 
     "iCalUId": "", 
     "reminderMinutesBeforeStart": 15, 
     "isReminderOn": true, 
     "hasAttachments": false, 
     "subject": "Moving (off work)", 
     "body": { 
     "contentType": "html", 
     "content": "" 
     }, 
     "bodyPreview": "", 
     "importance": "normal", 
     "sensitivity": "normal", 
     "start": { 
     "dateTime": "2016-09-10T00:00:00.0000000", 
     "timeZone": "UTC" 
     }, 
     "end": { 
     "dateTime": "2016-09-13T00:00:00.0000000", 
     "timeZone": "UTC" 
     }, 
     "location": { 
     "displayName": "", 
     "address": {} 
     }, 
     "isAllDay": true, 
     "isCancelled": false, 
     "isOrganizer": true, 
     "recurrence": null, 
     "responseRequested": true, 
     "seriesMasterId": null, 
     "showAs": "oof", 
     "type": "singleInstance", 
     "attendees": [], 
     "organizer": { 
     "emailAddress": { 
      "name": "", 
      "address": "" 
     } 
     }, 
     "webLink": "https://outlook.office365.com/owa/?ItemID=" 
    }, 
    { 
     "@odata.etag": "", 
     "id": "", 
     "createdDateTime": "2016-09-13T19:05:20.8438647Z", 
     "lastModifiedDateTime": "2016-09-13T19:05:22.1899702Z", 
     "changeKey": "", 
     "categories": [], 
     "originalStartTimeZone": "America/New_York", 
     "originalEndTimeZone": "America/New_York", 
     "responseStatus": { 
     "response": "organizer", 
     "time": "0001-01-01T00:00:00Z" 
     }, 
     "iCalUId": "", 
     "reminderMinutesBeforeStart": 15, 
     "isReminderOn": true, 
     "hasAttachments": false, 
     "subject": "Coffee Break", 
     "body": { 
     "contentType": "html", 
     "content": "" 
     }, 
     "bodyPreview": "", 
     "importance": "normal", 
     "sensitivity": "normal", 
     "start": { 
     "dateTime": "2016-09-15T20:15:00.0000000", 
     "timeZone": "UTC" 
     }, 
     "end": { 
     "dateTime": "2016-09-15T21:15:00.0000000", 
     "timeZone": "UTC" 
     }, 
     "location": { 
     "displayName": "", 
     "address": {} 
     }, 
     "isAllDay": false, 
     "isCancelled": false, 
     "isOrganizer": true, 
     "recurrence": null, 
     "responseRequested": true, 
     "seriesMasterId": null, 
     "showAs": "busy", 
     "type": "singleInstance", 
     "attendees": [], 
     "organizer": { 
     "emailAddress": { 
      "name": "", 
      "address": "" 
     } 
     }, 
     "webLink": "https://outlook.office365.com/owa/?ItemID=" 
    } 
    ] 
} 

여기 내 샘플 요청입니다. 궁극적으로, 내 Laravel 앱은 4 개월 만에 시작되는 이벤트를 동기화하려고 시도하고 있으며, 앞으로도 영원히 갈 것입니다.

더 효율적이고 효과적인 방법이 있다면 제안을 할 수 있습니다. 중요하다면이 결과는 우편 배달부에서 생성되었습니다. 이것에 대한 도움이나 명쾌함이 인정됩니다.

답변

1

나는 사용하여 종료 된 odata filter과 같이 :

https://graph.microsoft.com/beta/me/calendar/calendarView?startDateTime=2016-05-01T00:00:00Z&endDateTime=2099-01-01T00:00:00Z&$filter=type eq 'singleInstance' and lastModifiedDateTime eq '2016-09-20T07:30:00+00:00' 

이 이벤트 유형은 singleInstance (안 반복되는 이벤트)이며, lastModifiedDateTime이 지난 후이다 2016-05-01T00:00:00Z (May 1st, 2016, midnight, UTC2099-01-01T00:00:00Z (January 1st, 2099, midnight, UTC) 사이에 예정된 모든 캘린더 일정을 가져옵니다 sync (이 예제에서는 2016-09-20T07:30:00+00:00)입니다. 이와

몇 가지 함정 :

  1. 은 물론,이 URL 인코딩되어 있지 않습니다. 그렇게해야 할 것입니다.
  2. lastModifiedDateTime 예제의 +가 올바르게 %2B으로 인코딩되었는지 확인하십시오. 그렇지 않으면 Graph API가이를 공간으로 처리하고 거부합니다.
  3. 반복 일정을 필터링하지 않으면 지금부터 2099 년까지 각각의 반복 일정을 받게됩니다. 이것은 events이 아닌 calendarViews의 목록을 가져 오는 특성입니다.

내가 다시 할 수 있다면, 아마도 돌아가서 전체 캘린더 동기화를 수행 할 것입니다. 그래프는이를 지원합니다 (믿을 수 있음). 난 단지 달력 전체를 동기화하고 싶지는 않았지만 날짜 범위만으로는 운명을 정한 것 같습니다.

반복되는 이벤트가 없어도 작동합니다.

UPDATE

내가 주로하기 때문에 내가 반복 이벤트의 부족을 데이터 동기화 무결성을 유지와 만난 지속적인 함정이 구현을 폐기 결국, 등이 대신 내가 실시간으로 캘린더 이벤트를 를 당겨 시간은이며 캐시를 유지 관리해야합니다. 다른 사람이 내 상황에 처하게되는 경우를 대비해서 조언을 해줍니다.

+0

이봐, 내가 어떻게 도와 줄 수 있는지 좀 더 자세히 설명해 줄 수 있니? 업데이트 된 이벤트 만 가져 오기를 어떻게 관리 했습니까? 매번 모든 사건을 해결 했니? –

+0

내가 끝낸 것은 자신의 캘린더 일정을 내 db로 다운로드하는 대신 동일한 끝점 (calendarView)을 사용하여 페이지를 방문 할 때 실시간으로 이벤트를 가져 오는 것입니다. lastModifiedDateTime을 사용하여 특정 시간 이후에 수정 된 이벤트를 가져올 수 있지만, 아무 것도 동기화하지 않아도 될 필요는 없습니다 (훨씬 쉽게). 사용자는 Outlook을 포함한 몇 가지 다른 달력 서비스의 이벤트를 표시하는 달력이 있습니다. 따라서 1 월을 클릭하면 1 월에있는 Outlook 캘린더보기에서 이벤트를 가져 와서 내 서버에 아무 것도 저장하지 않습니다. –