我正在尝试将 Google Calendar API 与 Js 集成到应用程序中。我尝试遵循Google Quickstart。如果我将示例代码粘贴到 HTML 文档中,更改 clientID 和 API 密钥,则当我在 Chrome 中打开该文件时,会收到附加错误。
还有,随着console.log(gapi.client)我回来null。
第一个代码块是调用gapi函数的地方(calendar_model.js)。
第二个块是我将 api 脚本链接到文档的地方(我需要通过 js 在名为 dependency.js 的文件中执行此操作)。
第三个块是我的index.js,我从这里调用dependency.js 中的函数。
console.log("first");
// Client ID and API key from the Developer Console
var CLIENT_ID = 'xxxxxxxxxxxxxxxxx.apps.googleusercontent.com';
var API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
// Array of API discovery doc URLs for APIs used by the quickstart
var DISCOVERY_DOCS = ["https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest"];
// Authorization scopes required by …Run Code Online (Sandbox Code Playgroud)