Orbiit / gunn-web-app

The source code for a web app that displays the Gunn schedule; the app itself is here:
https://orbiit.github.io/gunn-web-app/
MIT License
12 stars 13 forks source link

Google Calendar API #18

Closed SheepTester closed 6 years ago

SheepTester commented 7 years ago

just dumping info here so i can rip the events from google calendar mauahahaha

helpful java file mi ne scias java, but the string concatenation of the url looks like something i can understand

basically it looks like

https://www.googleapis.com/calendar/v3/calendars/[CALENDARID]/events?key=[KEY]&timeMin=[???]&timeMax=[???]&maxResults=20&showDeleted=false&singleEvents=true&orderBy=startTime

this is what i get with just the keys

can use the ajax thingy

var xmlHttp=new XMLHttpRequest();
xmlHttp.onreadystatechange=function(){
  if (xmlHttp.readyState===4) {
    if (xmlHttp.status===200) // xmlHttp.responseText has the stuff
  }
};
xmlHttp.open("GET",URL,true); // true for asynchronous
xmlHttp.send(null);

with JSON.parse and do things

heaucques commented 7 years ago

Should you just embed it as an iframe or something or however you say that

SheepTester commented 7 years ago

@Velosify no because then I won't be able to access its contents

heaucques commented 7 years ago

@SheepTester sad

SheepTester commented 7 years ago

oops I meant

then I won't be able to change its styles

heaucques commented 7 years ago

@SheepTester Oh I see I can't seem to change font-family with CSS on the embedded calendar located on the gunn website

SheepTester commented 7 years ago

@Velosify you'll have to specify a userstyle for the embed URL of the iframe

var d=new Date();
`https://www.googleapis.com/calendar/v3/calendars/u5mgb2vlddfj70d7frf3r015h0@group.calendar.google.com/events?key=AIzaSyDBYs4DdIaTjYx5WDz6nfdEAftXuctZV0o&timeMin=${new Date(d.getFullYear(),d.getMonth(),d.getDate()).toISOString()}&timeMax=${new Date(d.getFullYear(),d.getMonth(),d.getDate()+5).toISOString()}&maxResults=20&showDeleted=false&singleEvents=true&orderBy=startTime`
SheepTester commented 7 years ago

Events now implemented! 🎆

SheepTester commented 6 years ago

Using the API explorer, a better GET query URL is:

https://www.googleapis.com/calendar/v3/calendars/u5mgb2vlddfj70d7frf3r015h0%40group.calendar.google.com/events?timeMax=2018-06-01T07%3A00%3A00.000Z&timeMin=2017-08-14T07%3A00%3A00.000Z&fields=items(description%2Cend(date%2CdateTime)%2Clocation%2Cstart(date%2CdateTime)%2Csummary)&key={YOUR_API_KEY}

Ugwa 2's steps for events are: (subject to change)

SheepTester commented 6 years ago

Edit: seems that "Winter Break Holiday" doesn't show up because it's a recurring event; it does show up with "singleEvents" set to "true," but it doesn't work if I select the entire school year :/

Compare

https://www.googleapis.com/calendar/v3/calendars/u5mgb2vlddfj70d7frf3r015h0%40group.calendar.google.com/events?timeMax=2018-06-01T07%3A00%3A00.000Z&timeMin=2017-08-14T07%3A00%3A00.000Z&fields=items(description%2Cend(date%2CdateTime)%2Clocation%2Crecurrence%2Cstart(date%2CdateTime)%2Csummary)&singleEvents=true&key={YOUR_API_KEY}

(entire school year, no "Winter Break Holiday") to

https://www.googleapis.com/calendar/v3/calendars/u5mgb2vlddfj70d7frf3r015h0%40group.calendar.google.com/events?timeMax=2018-01-01T07%3A00%3A00.000Z&timeMin=2017-12-14T07%3A00%3A00.000Z&fields=items(description%2Cend(date%2CdateTime)%2Clocation%2Crecurrence%2Cstart(date%2CdateTime)%2Csummary)&singleEvents=true&key={YOUR_API_KEY}

(December 14th, 2017 to January 1st, 2017, "Winter Break Holiday" apparent)

SheepTester commented 6 years ago

calendarId u5mgb2vlddfj70d7frf3r015h0@group.calendar.google.com timeMax 2018-06-01T07:00:00.000Z or 2018-01-01T07:00:00.000Z timeMin 2017-08-14T07:00:00.000Z or 2017-12-14T07:00:00.000Z fields items(description,end(date,dateTime),iCalUID,location,start(date,dateTime),summary) singleEvents true

SheepTester commented 6 years ago

Oh no recurrence rules.

Fortunately, the only ones I see use this format:

RRULE:FREQ=[WEEKLY:DAILY];UNTIL=<time>;INTERVAL=<int>;BYDAY=<day>
SheepTester commented 6 years ago

Events should work okay now