platform.js 还是 api.js? google api

platform.js or api.js? google api

试图了解我应该如何为静态页面 Web 应用程序引用 google API。我很困惑。

  1. 我不确定完整的文档在哪里,因为我已经在这个存储库中偶然发现了一些损坏的链接
  2. 这些教程参考了 2 个不同的 url,但似乎与此相关 repository

https://developers.google.com/identity/sign-in/web/reference#gapiauth2initparams

<script src="https://apis.google.com/js/platform.js?onload=init" async defer></script>

https://developers.google.com/sheets/api/quickstart/js

<script async defer src="https://apis.google.com/js/api.js"
      onload="this.onload=function(){};handleClientLoad()"
      onreadystatechange="if (this.readyState === 'complete') this.onload()">

有什么区别? url 应该使用什么?有关系吗? 是否应该使用节点客户端而不是 Web 来编译它?

专业提示。不要使用 JS API 库。麻烦多于它的价值。 API 是一个格式良好的 REST API,因此它很容易与任何 http 库一起使用,例如 Axios,甚至 fetch.

https://github.com/google/google-api-javascript-client/issues/658#issuecomment-692839901

sergentj 评论

The functionality in platform.js is a superset of the functionality in api.js. The documentation for those APIs is correct. If you are using both the sheets APIs and the sign-in API, platform.js will suffice, you needn't load both. You are correct that this is poorly documented, and we're aware that's a problem. Closing this since it is not going to be useful to track work on improving documentation (which is a much larger issue) here.