locked
Adding an item to a users calendar.

    Question

  • It seems there is no other way to access a users calendar other than something such as the "Live Connect" API...I am trying to implement it.

    It appears even for testing purposes you must have a windows store account according to http://go.microsoft.com/fwlink/?LinkId=220871 which says you need a package identity you can get after submitting the app to the store...so I go through everything, even able to get my app published, but the app isn't working...in debug mode, it says visit that URL because my app is either disabled or incorrectly configured so it can't request authentication tokens...

    My question is, do I need to be putting something extra in my code somewhere for the package identity? Because my app is still not working after being published.

    This is my code for debug mode to just get something simple output to me.

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title>App6</title>
        <!-- WinJS references -->
        <link href="//Microsoft.WinJS.2.0/css/ui-dark.css" rel="stylesheet" />
        <script src="//Microsoft.WinJS.2.0/js/base.js"></script>
        <script src="//Microsoft.WinJS.2.0/js/ui.js"></script>
        <script src="js/wl%20-%20Copy.js"></script>
        <script type="text/javascript">
            WL.init()
            WL.login({ scope: "wl.calendars" }).then(
                function (response) {
                    getEvents();
                },
                function (response) {
                    log("Could not connect, status = " + response.status);
                }
             );
    
            function getEvents() {
                WL.api({
                    path: "/me/events",
                    method: "GET"
                }).then(
                    onGetEvents,
                    function (response) {
                        log("Cannot get events: " + JSON.stringify(response.error).replace(/,/g, ",\n"));
                    }
                );
            }
    
            function onGetEvents(response) {
                var items = response.data;
                for (var i = 0; i < 5; i++) {
                    if (i > items.length) {
                        break;
                    }
    
                    getEventProperties(items[i].id);
                }
            }
    
            function getEventProperties(eventId) {
                WL.api({
                    path: eventId,
                    method: "GET"
                }).then(onGetEventProperties);
            }
    
            function onGetEventProperties(response) {
                log(JSON.stringify(response).replace(/,/g, ",\n"));
            }
    
            function log(message) {
                var child = document.createTextNode(message);
                var parent = document.getElementById('JsOutputDiv') || document.body;
                parent.appendChild(child);
                parent.appendChild(document.createElement("br"));
            }
        </script>
    
        <!-- App5 references -->
        <link href="/css/default.css" rel="stylesheet" />
        <script src="/js/default.js"></script>
    </head>
    <body>
        <p>Content goes here</p>
    </body>
    </html>
    • Edited by Maya Key Saturday, February 1, 2014 4:31 PM
    Saturday, February 1, 2014 4:24 PM

Answers

  • If you're targeting Windows 8.1, you could consider using the API in Windows.ApplicationModel.Appointments.AppointmentsManager, which gives you a simple way to add/remove/update appointments on the users calendar through whatever provider app is handling those requests. This is the built-in Calendar by default which then ties into the user's Microsoft Account, of course. So this could be a much easier way to achieve your scenario without having to use the Live SDK. 
    Saturday, February 1, 2014 5:33 PM

All replies

  • If you're targeting Windows 8.1, you could consider using the API in Windows.ApplicationModel.Appointments.AppointmentsManager, which gives you a simple way to add/remove/update appointments on the users calendar through whatever provider app is handling those requests. This is the built-in Calendar by default which then ties into the user's Microsoft Account, of course. So this could be a much easier way to achieve your scenario without having to use the Live SDK. 
    Saturday, February 1, 2014 5:33 PM
  • It's nice to know that's an option, but is there a way to simply add the appointment without using ShowAddAppointmentAsync?  So it can be more automatic...?  For example without recursion I want to be able to quickly add events to the calendar...as it's now, once their done using my UI  to specify everything they want to add on the calendar, it'd have to show the dialog for each and every event added...is there any way to automate this so there is nothing extra needed to be done before they are actually put on the calendar?
    Saturday, February 1, 2014 7:31 PM
  • no. user needs to agree your app is adding appointments.

    if dont want to have the dialog you need to connect directly to the backend (if there is one)


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#


    Sunday, February 2, 2014 11:23 AM
  • Not with the appointments API--it's designed for user consent. So it sounds like you're back to your original question, but I don't have anything to add there. Sorry for the distraction.

    Monday, February 3, 2014 3:37 AM