-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Displaying Upcoming Events From a Google Calendar in Web #21
Comments
Getting a From https://productforums.google.com/forum/#!topic/calendar/mZSk3FXR_KY (2012) we read:
Let's check out v3! |
https://developers.google.com/calendar/quickstart/js works nicely, but must
|
Much better: function listCals() {
gapi.client.calendar.calendarList.list({
'maxResults': 10,
}).then(function(response) {
var events = response.result.items;
console.dir(events);
appendPre('CalendarIDs:');
if (events.length > 0) {
for (i = 0; i < events.length; i++) {
// var event = events[i];
appendPre(events[i].id);
}
} else {
appendPre('No calendarIDs found.');
}
});
} |
...where we discover the private/secret calendar ID
|
Previous code required too much auth. Jquery/AJAX was not working, but CORS does work. <!DOCTYPE html>
<html>
<body>
<h2>Using the XMLHttpRequest Object</h2>
<div id="demo">
<button type="button" onclick="loadXMLDoc()">Change Content</button>
</div>
<script>
function loadXMLDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "https://www.googleapis.com/calendar/v3/calendars/[email protected]/events?key=xxxxxxxxxxxxxxxxxxxxxx", true);
xhttp.send();
}
</script>
</body>
</html> |
And from https://docs.simplecalendar.io/google-api-key/ we read: |
Seems like key is restricted to Calendar, but cannot have finer granularity on control other than: This is, no read-only permissions, which would be interesting. |
Also have been looking at "github pages hide api key", some interesting posts: |
Public URL from #21 (comment) + (https://pypi.org/project/ics/ = https://icspy.readthedocs.io/en/stable/ = https://github.com/C4ptainCrunch/ics.py) looks good. |
from ics import Calendar
from urllib.request import urlopen
import arrow
from datetime import datetime
import locale
locale.setlocale(locale.LC_ALL, 'es_ES.utf8') # es-ES, check `locale -a`
url = "https://calendar.google.com/calendar/ical/e97mebpnhjcq8pbl28plc8l3is%40group.calendar.google.com/public/basic.ics"
calendar = Calendar(urlopen(url).read().decode())
now = arrow.get(datetime.now())
events = list(calendar.timeline.start_after(now))
for event in events:
if (event.name == 'Reunión Robot Devastation'): # 'Rd Meeting'
dt = event.begin.datetime
print(dt.strftime("%A %d de %B a %H:%M") + " en " + event.location) |
La idea es evitar varios commits semanales que son simplemente para actualizar la fecha de la reunión.
https://kevin.deldycke.com/2012/07/displaying-upcoming-events-google-calendar-javascript/
From @jgvictores on June 22, 2018 17:24
Copied from original issue: asrob-uc3m/actas#152
The text was updated successfully, but these errors were encountered: