0
votes

Tools:

  • Php (programming language)
  • MySQL database (to store events)
  • Office 365 API (to interact with calendars from office 365)

I'm making a small system that reads in the events from a calendar every 5 minutes and displays them on a webpage. I achieve this by auto-refreshing the page every 5 minutes <meta http-equiv="refresh" content="10">, when the page gets loaded it calls the API to get the newest events.

I chose to pick an auto-refresh rate because I didn't find any possibility/setting to make the calendar push data to my webpage when a new event is created. This would be better because then the webpage doesn't have to refresh every 5 minutes.

So my question: can the calendar of office 365 push data/generate a signal to my webpage so it can refresh only when the calendar has new event? If not, is there any other way to achieve this?

Thanks for your time

1

1 Answers

1
votes

Another choice is to use Notifications REST API, the API could be used to subscribe to changes in your calendar, mailbox, and contacts .You could get notifications for a top level entity collection of messages, events or contacts, below example shows how to subscribe to new events :

POST https://outlook.office.com/api/v2.0/me/subscriptions HTTP/1.1
Content-Type: application/json

{
   @odata.type:"#Microsoft.OutlookServices.PushSubscription",
   Resource: "https://outlook.office.com/api/v2.0/me/events",
    NotificationURL: "https://mywebhook.azurewebsites.net/api/send/myNotifyClient",  
   ChangeType: "Created",
   ClientState: "c75831bd-fad3-4191-9a66-280a48528679"
}

When a triggering event occurs ,Office 365 pushes a notification via a webhook to the callback URL. Your app, in turn, takes actions according to your business logic, for example , update your local cache, corresponding client views, or backend system upon changes.