Hello, for some reason I get a javascript error "authorization
required" when trying to add and event to the google calendar.  Here
is my code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta name="verify-v1"
content="0cON1PImRKuCO0wUUGq9o4H395CF7LXzSA8+IGLonWs=" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://www.google.com/jsapi?
key=Key"></script>

<script type="text/javascript">
google.load("gdata", "1");

var scope = "http://www.google.com/calendar/feeds/";;
google.setOnLoadCallback(getMyFeed);

function getUrlParam(name) {
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return null;
  else
    return results[1];
}
function authSubRequest() {


    var url = 'https://www.google.com/accounts/AuthSubRequest?';
   url += 'scope=' + scope;
   url += '&session=1&secure=0&';
   url += 'next=' + "http://www.jbampton.com/gc1.html";;

   window.location = url;
 }


function getMyFeed(){

        var token = getUrlParam('token');

        if (token == null) {
                authSubRequest()
        }else{
                var calendarService = new google.gdata.calendar.CalendarService
('GoogleInc-jsguide-1.0');
                var mycookie = 
'g314-http%3A%2F%2Fwww.google.com%2Fcalendar%2Ffeeds
%2F=' + token;
                document.cookie = mycookie;



                // The default "private/full" feed is used to insert event to 
the
                // primary calendar of the authenticated user
                var feedUri = 
'http://www.google.com/calendar/feeds/default/private/
full';

                // Create an instance of CalendarEventEntry representing the new
event
                var entry = new google.gdata.calendar.CalendarEventEntry();

                // Set the title of the event
                entry.setTitle(google.gdata.Text.create('javascript event'));

                // Create a When object that will be attached to the event
                var when = new google.gdata.When();

                // Set the start and end time of the When object
                var startTime = google.gdata.DateTime.fromIso8601
("2009-05-10T09:00:00.000-08:00");
                var endTime = google.gdata.DateTime.fromIso8601
("2009-05-10T10:00:00.000-08:00");
                when.setStartTime(startTime);
                when.setEndTime(endTime);

                // Add the When object to the event
                entry.addTime(when);

                // The callback method that will be called after a successful
insertion from insertEntry()
                var callback = function(result) {
                  alert('event created!');
                }

                // Error handler will be invoked if there is an error from
insertEntry()
                var handleError = function(error) {
                  alert(error);
                }

                // Submit the request using the calendar service object
                calendarService.insertEntry(feedUri, entry, callback,
                        handleError, google.gdata.calendar.CalendarEventEntry);

        }

}

</script>

</head>

<body>

        <img src="1.jpg" style="position:absolute; top: -1000px;">

</body>
</html>

But it has worked with no error a couple of times????

Can anyone help me please?

Regards

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Calendar Data API" group.
To post to this group, send email to 
[email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to