I’ve been trying to work with the Google Calendar JSON API, but have been running into some issues.
I’ve managed to get it working with jQuery, but for some reason the JSON google is providing is not ordered by date, and also seems to be leaving out some events.
Here is the code I’m using:
<script>
$.getJSON("http://www.google.com/calendar/feeds/weimar.org_cnijr5sa383f7kl28eu63996ec%40group.calendar.google.com/public/full?alt=json-in-script&max-results=25&singleevents=false&futureevents=true&sortorder=descending&callback=?",
function(json){
var html = '<ul id="event_feed">';
$.each(json.feed.entry,function(i,entry) {
html += '<li>' + $.format.date(entry['gd$when'][0].startTime + ' 00:00:00.000', "yyyy-MM-dd") + '</li>';
})
html += '</ul>';
$('#calendar').html(html);
});
</script>
How can this be fixed? To keep things simple for now I’m simply appending the date of each event to a div. The format.date() is simply a plugin I’m using to reformat the date.
Give this a go: