How to get list of calender and events from outlook calendar.
Problem: How to get list of calendar and events from outlook.com, How to import events from outlook calendar.
Requirement:
- Microsoft account.
- Create some event on outlook calendar by using outlook.com
Solution:
2. Log in with this url http://msdn.microsoft.com/en-us/onedrive/dn632140
3. After login click on Dashboard Menu.
4. After that Click on MyApps Menu
5. Then create you application there
Enter you application name and click I accept button.
6. After that you will see the Apps setting window.
Click On API Settings and enter you redirect url .
NOTE: Here localhost, IP not allowed please use you real domain name.
E.g: http://domain.com/outlook_calendar/calendar.php
7. In APP Settings you see your Client ID and Client Secret
8. In you domain directory create new directory and one php file.
E.g:http://domain.com/outlook_calendar/calendar.php
9. Open calendar.php file and Paste following code.
<script src="//js.live.net/v5.0/wl.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript">
WL.init({
client_id: 'YOUR_CLIENT_ID',
redirect_uri: 'http://domain.com/outlook_calendar/calendar.php',
scope: "wl.signin",
response_type: "token"
});
function streamlineAccountReg_onClick() {
calander_array = [];
event_array = [];
WL.login({
scope: ["wl.signin", "wl.calendars"]
}).then(
function(response) {
WL.api({
path: "me/calendars",
method: "GET"
}).then(
function(response) {
for (i = 0; i < response.data.length; i++) {
calander_array.push({'index': i, 'id': response.data[i].id, 'name': response.data[i].name});
$('#myCalanderList').append('<li><b>Name:</b>' + response.data[i].name + '</li>');
}
console.log(JSON.stringify(calander_array));
onReadEvent();
},
function(responseFailed) {
document.getElementById("infoArea").innerText =
"Error calling API: " + responseFailed.error.message;
}
);
},
function(responseFailed)
{
document.getElementById("infoArea").innerText =
"Error signing in: " + responseFailed.error_description;
}
);
}
function onReadEvent() {
WL.login({
scope: "wl.calendars"
}).then(
function(response) {
WL.api({
path: "me/events",
method: "GET"
}).then(
function(response) {
for (i = 0; i < response.data.length; i++) {
event_array.push({'index': i, 'id': response.data[i].id, 'name': response.data[i].name});
$('#myEventlist').append('<li><b>Name:</b>' + response.data[i].name + '</li>');
}
console.log(JSON.stringify(event_array));
},
function(responseFailed) {
document.getElementById("infoArea").innerText =
"Error calling API: " + responseFailed.error.message;
}
);
},
function(responseFailed) {
document.getElementById("infoArea").innerText =
"Error signing in: " + responseFailed.error_description;
}
);
}
</script>
<button onclick="streamlineAccountReg_onClick()">Login</button>
<h3>My Calander list</h3>
<ul id="myCalanderList"></ul>
<br>
<h3>My Event list</h3>
<ul id="myEventlist"></ul>
Click on login button for display result.
That sit. You will see all calendar and event list.
For more methods for calender and events use following url.
Comments
Post a Comment