views:

44

answers:

1

Using the Google Javascript API I am trying to authenticate myself (locally) to create a new event in my calendar. However, I get an error (see below) stating that my "next" parameter is bad or missing when I execute the log-in portion of the script. I am following the data api interactive samples for "Create a single event".

Update 1: From the address bar I see "next" set the following way:

next=file:///C:/calext/sending_data.html

Does Google not like local files? Workaround?

Update 2: I tried running the file on my web host. The page ran (threw a few errors) but the event ended up on my calendar. So the bug lies somewhere with not liking local files. Thoughts?

Error Message:

The page you have requested cannot be displayed. Another site was requesting access to your Google Account, but sent a malformed request. Please contact the site that you were trying to use when you received this message to inform them of the error. A detailed error message follows:

The "next" parameter was bad or missing.

My page's code:

<html>

<head>
<script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt;
</head>

<body>

<img src="128.png">

<script type="text/javascript">
var myService;
var feedUrl = "https://www.google.com/calendar/feeds/default/private/full";

google.load("gdata", "1");
google.setOnLoadCallback(getMyFeed); // starts process

// Create a single event example
function doExample()
{
    var calendarService = myService;

    // 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('JS-Client: insert 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("2010-10-24T09:00:00.000-05:00");
    var endTime = google.gdata.DateTime.fromIso8601("2010-10-24T10:00:00.000-05:00");
    when.setStartTime(startTime);
    when.setEndTime(endTime);

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

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

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 getMyFeed()
{
    // Set up my service
    myService = new google.gdata.calendar.CalendarService('GoogleInc-jsguide-1.0');

    // Log me in
    var scope = "https://www.google.com/calendar/feeds/";
    var token = google.accounts.user.login(scope);

    // Create a single event example
    doExample();

    // Get my feed
    myService.getEventsFeed(feedUrl, handleMyFeed, handleError);
}

</script>

</body>
</html>
A: 

I assume your opening a local file which requires a local file. By default, file:// URIs cannot read other file:// URIs. Try adding this command line parameter, it is specifically made to help developers test:

chrome --allow-file-access-from-files

Mohamed Mansour