Hello,
I'm new with Google Calendar API and I'm facing some problems when
trying to create a token and loging in a user.
The login page loads correctly, the user is able to select the account
he would like to use and Grant the correct Authorization for the code
to run, but google.accounts.user.checkLogin always returns as the user
was never logged in, so the page always request the user to login over
and over.
I'm pretty sure I'm doing something wrong, I just can't figure out
what...
This is my script:
<script src="http://www.google.com/jsapi?key=[[MY KEY]]"
type="text/javascript"></script>
<script src="includes/jquery.js" type="text/javascript"></script>
<script type="text/javascript">
google.load("gdata", "1");
google.setOnLoadCallback(main);
function handleInfo(data) {
var response = eval(data.currentTarget.responseText);
alert('Target: ' + response.Target + "\n" +
'Scope: ' + response.Scope + "\n" +
'Secure: ' + response.Secure);
}
function main() {
var scope = "http://www.google.com/calendar/feeds/";
var token = google.accounts.user.checkLogin(scope);
if (token==""){
google.accounts.user.getInfo(handleInfo);
google.accounts.user.login(scope);
} else {
var feedUri = 'http://www.google.com/calendar/feeds/[[MY
[email protected]/private/full';
var calendarService = new
google.gdata.calendar.CalendarService
('GoogleInc-jsguide-1.0');
var entry = new
google.gdata.calendar.CalendarEventEntry();
entry.setTitle(google.gdata.Text.create('ABC'));
var when = new google.gdata.When();
var startTime =
google.gdata.DateTime.fromIso8601
("2009-08-22\T14:00:00.000-03:00");
var endTime = google.gdata.DateTime.fromIso8601
("2009-08-22\T16:00:00.000-03:00");
when.setStartTime(startTime);
when.setEndTime(endTime);
entry.addTime(when);
var callback = function(result) {
document.write('event created!');
}
var handleError = function(error) {
document.write(error);
}
calendarService.insertEntry(feedUri, entry, callback,
handleError,
google.gdata.calendar.CalendarEventEntry);
$.post("includes/atualiza.php", { id:22 },
function(data) { alert
(data); }, 'html');
}
google.accounts.user.logout();
}
</script>
<img src="anything.png" style="position:absolute; top:-1000px;" />
Can someone, please, help me with this code?
Thanks!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---