:spreadshop: Tipps und Tricks: Die besten Lifehacks

Promotions anzeigen/auslesen

Read and parse the google calendar feed:

API Documentation: Events: list  |  Google Calendar  |  Google for Developers

Code:

<script src="https://apis.google.com/js/api.js"></script>
<script>
  /**
   * Sample JavaScript code for calendar.events.list
   * See instructions for running APIs Explorer code samples locally:
   * https://developers.google.com/explorer-help/guides/code_samples#javascript
   */

  function loadClient() {
    gapi.client.setApiKey(YOUR_API_KEY);
    return gapi.client.load("https://content.googleapis.com/discovery/v1/apis/calendar/v3/rest")
        .then(function() { console.log("GAPI client loaded for API"); },
              function(err) { console.error("Error loading GAPI client for API", err); });
  }
  // Make sure the client is loaded before calling this method.
  function execute() {
    return gapi.client.calendar.events.list({
      "calendarId": "o7bpn74u6mp2jmfn2d6fkukti8@group.calendar.google.com",
      "timeZone": "Europe/Berlin"
    })
        .then(function(response) {
                // Handle the results here (response.result has the parsed body).
                console.log("Response", response);
              },
              function(err) { console.error("Execute error", err); });
  }
  gapi.load("client");
</script>
<button onclick="loadClient()">load</button>
<button onclick="execute()">execute</button>

Alternative (read promotion of your own shop):

https://codepen.io/thimo1/pen/eLOoPW

4 Likes