google api calendar add event
<p>i tried to insret event to my google calenadr  trow javaScript code :</p>

<pre><code>&lt;script&gt;

        var apiKey = 'AIraSyDFMA8t3fTM6cqflPEDys1rXhPffARFiEs';

        var clientId = '---------';

        var scopes = 'https://www.googleapis.com/auth/calendar';

        // The Calendar entry to create
        var resource = {
            "summary": "Appointment",
            "location": "Somewhere",
            "start": {
                "dateTime": "2012-12-16T10:00:00.000-07:00"
            },
            "end": {
                "dateTime": "2012-12-16T10:25:00.000-07:00"
            }
        };

        function init() {
            gapi.client.setApiKey(apiKey);
            gapi.auth.init(load);
        }

        function load() {
            gapi.client.load('calendar', 'v3', auth);
        }

        function auth() {
            gapi.auth.authorize({
                'client_id': clientId,
                'scope': scopes,
                'immediate': false
            });
        }

        function makeRpcRequest() {
            var request = gapi.client.calendar.events.insert({
                'calendarId': 'primary',
                'resource': resource
            });
            request.execute(writeResponse);
        }

        function makeRestRequest() {
            gapi.client.request({
                'path': '/calendar/v3/calendars/primary/events',
                'method': 'POST',
                'body': resource,
                'callback': writeResponse
            });
        }

        function writeResponse(response) {
            console.log(response);
            var creator = response.creator.email;
            var calendarEntry = response.htmlLink;
            var infoDiv = document.getElementById('info');
            var infoMsg = document.createElement('P');
            infoMsg.appendChild(document.createTextNode('Calendar entry ' +
            'successfully created by ' + creator));
            infoDiv.appendChild(infoMsg);
            var entryLink = document.createElement('A');
            entryLink.href = calendarEntry;
            entryLink.appendChild(
            document.createTextNode('View the Calendar entry'));
            infoDiv.appendChild(entryLink);
        }
    &lt;/script&gt;
</code></pre>

<p>it's not working pleas help </p>
