This web page talks about how you can arrange and use Google Calendar API. It talks a few Python server. I wish to know is {that a} should? Or may you utilize one other net server like XAMPP or a stay one? Thanks
The reply to my query isn’t any. It isn’t a should. I simply used Docker working XAMMP to attach and use the pattern, and I pulled all calendar occasions!
Hello @philhagen, really you won’t even want docker, or a full XAMPP setup for that matter… as I perceive it, they’re utilizing python only for a easy static file server to serve the index.html
web page. So you may also use the builtin PHP dev server like so:
php -S localhost:8000
… after which open http://localhost:8000 in your browser. Or use some other dev server like e.g. this vscode plugin, which I’m utilizing on a regular basis for such issues:
1 Like
Hey, thanks for the reply. I noticed that. Nonetheless, was simply attempting to remain in line with the opposite factor my software is doing. I wished to make use of the present server and have one other working, easy or not. Thanks
1 Like
If anyone has an concept on how you can change the page’s code I hyperlink to so it may pull all occasions and never simply the up coming occasions. Please let me know. Thanks
I don’t know for certain, however in listUpcomingEvents()
, they’re setting
request =
'calendarId': 'major',
'timeMin': (new Date()).toISOString(),
// ...
So’d most likely simply have to set timeMin
to some date up to now (or perhaps omit it completely).
Edit: Yup appears the timeMin
parameter is certainly non-obligatory, so leaving it off ought to provide the full record of occasions:
Thanks! Tremendous useful. Humorous sufficient, I attempted to eradicate it. I didn’t understand that these requests additionally will be affected by caching. I didn’t see something till I closed the window and opened a brand new one. Whenever you stated it was working, I spotted one thing bizarre was taking place.
1 Like
Additionally… would this be what they are saying ought to work to insert an occasion?
<!DOCTYPE html>
<html>
<head>
<title>Google Calendar API Quickstart</title>
<meta charset="utf-8" />
</head>
<physique>
<p>Google Calendar API Quickstart</p>
<!--Add buttons to provoke auth sequence and signal out-->
<button id="authorize_button" onclick="handleAuthClick()">Authorize</button>
<button id="signout_button" onclick="handleSignoutClick()">Signal Out</button>
<pre id="content material" type="white-space: pre-wrap;"></pre>
<script kind="textual content/javascript">
/* exported gapiLoaded */
/* exported gisLoaded */
/* exported handleAuthClick */
/* exported handleSignoutClick */
// TODO(developer): Set to shopper ID and API key from the Developer Console
const CLIENT_ID = '<YOUR_CLIENT_ID>';
const API_KEY = '<YOUR_API_KEY>';
// Discovery doc URL for APIs utilized by the quickstart
const DISCOVERY_DOC = 'https://www.googleapis.com/discovery/v1/apis/calendar/v3/relaxation';
// Authorization scopes required by the API; a number of scopes will be
// included, separated by areas.
const SCOPES = 'https://www.googleapis.com/auth/calendar';
let tokenClient;
let gapiInited = false;
let gisInited = false;
doc.getElementById('authorize_button').type.visibility = 'hidden';
doc.getElementById('signout_button').type.visibility = 'hidden';
/**
* Callback after api.js is loaded.
*/
perform gapiLoaded()
gapi.load('shopper', initializeGapiClient);
/**
* Callback after the API shopper is loaded. Masses the
* discovery doc to initialize the API.
*/
async perform initializeGapiClient()
await gapi.shopper.init(
apiKey: API_KEY,
discoveryDocs: [DISCOVERY_DOC],
);
gapiInited = true;
maybeEnableButtons();
/**
* Callback after Google Id Companies are loaded.
*/
perform gisLoaded()
tokenClient = google.accounts.oauth2.initTokenClient(
client_id: CLIENT_ID,
scope: SCOPES,
callback: '', // outlined later
);
gisInited = true;
maybeEnableButtons();
/**
* Allows consumer interplay in spite of everything libraries are loaded.
*/
perform maybeEnableButtons()
if (gapiInited && gisInited)
doc.getElementById('authorize_button').type.visibility = 'seen';
/**
* Signal within the consumer upon button click on.
*/
perform handleAuthClick()
tokenClient.callback = async (resp) =>
if (resp.error !== undefined)
throw (resp);
doc.getElementById('signout_button').type.visibility = 'seen';
doc.getElementById('authorize_button').innerText="Refresh";
await listUpcomingEvents();
;
if (gapi.shopper.getToken() === null)
// Immediate the consumer to pick a Google Account and ask for consent to share their knowledge
// when establishing a brand new session.
tokenClient.requestAccessToken(immediate: 'consent');
else
// Skip show of account chooser and consent dialog for an current session.
tokenClient.requestAccessToken(immediate: '');
/**
* Signal out the consumer upon button click on.
*/
var occasion =
'abstract': 'Google I/O 2015',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'An opportunity to listen to extra about Google's developer merchandise.',
'begin':
'dateTime': '2023-05-28T09:00:00-07:00',
'timeZone': 'America/Los_Angeles'
,
'finish':
'dateTime': '2023-05-28T17:00:00-07:00',
'timeZone': 'America/Los_Angeles'
,
'recurrence': [
'RRULE:FREQ=DAILY;COUNT=2'
],
'attendees': [
'email': '[email protected]',
'email': '[email protected]'
],
'reminders':
'useDefault': false,
'overrides': [
'method': 'email', 'minutes': 24 * 60,
'method': 'popup', 'minutes': 10
]
;
var request = gapi.shopper.calendar.occasions.insert(
'calendarId': 'major',
'useful resource': occasion
);
request.execute(perform(occasion)
appendPre('Occasion created: ' + occasion.htmlLink);
);
</script>
<script async defer src="https://apis.google.com/js/api.js" onload="gapiLoaded()"></script>
<script async defer src="https://accounts.google.com/gsi/shopper" onload="gisLoaded()"></script>
</physique>
</html>