Add calender event in office 365 using php
Outlook calendar is part of the Outlook messaging hub in Microsoft 365 that also lets you manage emails and contacts, find information about users in an organization, initiate online conversations, share files, and collaborate in groups. ( Add calender event in office 365 using php)
API features used
- Creating events on a user’s default calendar
- Adding attachments to events
- Adding attendees to events
- Using a calendar view to expand recurring events and display all appointments for a single day.
Required software
- PHP 5.6
- A web server capable of serving PHP.
In my testing I used IIS 8 installed on a Windows 8.1 laptop. I installed PHP 5.6.0 using the Web Platform Installer (Windows/IIS only).
Running the sample
It’s assumed that you have PHP installed before starting, and that your web server is configured to process and server PHP files.
-
Download or fork the sample project.
-
Create a new directory in your web root directory called
php-calendar
. Copy the files from the repository to this directory. -
Register the app in Azure Active Directory. The app should be registered as a web app with a Sign-on URL of
http://localhost/php-calendar
, and should be given the permission to “Have full access to users’ calendars”, which is available in the “Delegated Permissions” dropdown. -
Edit the
.\o365\ClientReg.php
file.- Copy the client ID for your app obtained during app registration and paste it as the value for the
$clientId
variable. - Copy the key you created during app registration and paste it as the value for the
$clientSecret
variable. - Save the file.
- Copy the client ID for your app obtained during app registration and paste it as the value for the
-
If your PHP installation is not configured with updated CA certificates to verify SSL, requests will fail unless you run Fiddler on the server and set the
$enableFiddler
variable totrue
inOffice365Service.php
. Alternatively, you can insert the following line immediately before any call tocurl_exec
. However, it should be noted that doing so disables any SSL verification, which should NOT be done in production.curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
-
Open a web browser and browse to
http://localhost/php-calendar/home.php
. -
You should see a list of upcoming show times for various Shakespearean plays. Click on any of the “Connect my Calendar” buttons to sign in to Office 365.
-
Once signed in you should be redi
-
rected back to the home page, and the buttons should now read “Add to Calendar.” Click the button next to a specific show time to add it to your calendar. Events with a “Voucher Required” field of Yes will include the voucher as an attachment on the event.