views:

26

answers:

0

Hi,

I am using the Google Data API in Javascript to access google calendar. But when I grant the access to the website for accessing my calendar, it should return to my first HTML page, but this doesn't happen and it redirects it to the same grant access page.

Anyone encountered this situation?

Thanks, Sana.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>My Google Data API Application</title>
    <script src="http://www.google.com/jsapi?key=ABQIAAAAFhJPzZXe1du8T6kJokgI1hRCO7UywR653-E7AP3kLUzoPzkV7xTiATQmt18hPECgoHDKCbKCnW0K7w" type="text/javascript"></script>
    <script type="text/javascript">
    //<![CDATA[

        google.setOnLoadCallback(getMyFeed);
        google.load("gdata", "1");
    var myService;
    var feedUrl = "https://www.google.com/calendar/feeds/[email protected]/private/full";

    function setupMyService() {
      myService = new google.gdata.calendar.CalendarService('exampleCo-exampleApp-1');
      logMeIn();
    }

    function logMeIn() {
          scope = "https://www.google.com/calendar/feeds/";
          var token = google.accounts.user.login(scope);
    }

    function logMeOut() {
          google.accounts.user.logout();
    }

    function doCheck(){
        scope = "http://www.google.com/calendar/feeds";
        var token = google.accounts.user.checkLogin(scope);
    }
        function getMyFeed() {
            setupMyService();
        myService.getEventsFeed(feedUrl, handleMyFeed, handleError);
    }
    function handleMyFeed(myResultsFeedRoot) {
          alert("This feed's title is: " + myResultsFeedRoot.feed.getTitle().getText());
    }

    function handleError(e) {
          alert("There was an error!");
          alert(e.cause ? e.cause.statusText : e.message);
    }

    function onLoad() {
        google.load("gdata", "1");

    }
    function insertEvent(title, startTime, endTime) {
        /*
         * Create a single event
         */ //startTime = "2008-02-10T09:00:00.000";
         //endTime = "2008-02-10T10:00:00.000";

        // Create the calendar service object
        var calendarService = new google.gdata.calendar.CalendarService('GoogleInc-jsguide-1.0');

        // 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(title));

        // 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(startTime);
        var endTime = google.gdata.DateTime.fromIso8601(endTime);
        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) {
          PRINT('event created!');
        }

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

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

    }

    //]]>
    </script>
  <title>Example</title>
  </head>
  <body bgcolor="#F8F8F8">
  <h1 align="center">Google Calendar Modify Events</h1>
  <div id="todoID" class="">
  <div id="todoListID" class=""></div>
  <div id="todoAttach" class=""></div>
  <button type="button" onclick="onLoad();">Load!</button>
  <button type="button" onclick="logMeIn();">Login!</button>
  <button type="button"  onclick="insertEvent('Inserting from WebPage','2010-08-15T09:00:00.000','2010-08-15T10:00:00.000');">Insert Event</button>
  <div id="listItemInfoID" class="" style="display:none"></div>
  </div>
  </body>
</html>