[英]Google Save To Drive API v3 stopped working
我希望有人能幫幫忙。
我們一直在使用 Google 的保存到驅動器按鈕 API,版本 3 來將我們系統生成的文檔保存到用戶的驅動器。 這在上周停止了一段時間。
在 JS 控制台中拋出的錯誤是:
Uncaught ReferenceError: _createSaveToDriveWidgetApplication is not defined
at https://drive.google.com/savetodrivebutton?usegapi=1&src=(redacted URL)&filename=My%20Statement.pdf&sitename=My%20Company%20Name&origin=https%3A%2F%2F(redacted URL)&gsrc=3p&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en_GB.sedaY3Dv4HE.O%2Fam%3DwQE%2Fd%3D1%2Fct%3Dzgms%2Frs%3DAGLTcCO2t4glYwUJ-eH43TAA_offcn6l6Q%2Fm%3D__features__
所以我使用在谷歌的 API 文檔上找到的演示源從頭開始設置它。
我的測試源代碼如下所示:
<!DOCTYPE html>
<html>
<head>
<title>Save to Drive Demo: Explicit Render</title>
<link rel="canonical" href="https://(redacted)">
<script src="https://apis.google.com/js/platform.js"></script>
<script>
window.___gcfg = {
parsetags: 'explicit'
};
</script>
</head>
<body>
<a href="javascript:void(0)" id="render-link">Render the Save to Drive button</a>
<div id="savetodrive-div"></div>
<script>
function renderSaveToDrive() {
gapi.savetodrive.render('savetodrive-div', {
src: 'https://(redacted)/go.php',
filename: 'My Statement.pdf',
sitename: 'My Company Name'
});
}
document.getElementById('render-link').addEventListener('click', renderSaveToDrive);
</script>
</body>
</html>
編輯后的文本是 URL,它們的協議、主機、域和端口完全相同。 此外,正在檢索的內容以以下響應標頭開始提供:
Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: Range
Access-Control-Expose-Headers: Cache-Control, Content-Encoding, Content-Range
即使我不需要 Origin header 因為 CORS 在這里沒有使用或不需要。
我在 MAC 和 Windows 上嘗試過 Chrome、Safari、Firefox,結果始終相同 - 調用 gapi.savetodrive.render 時,它停止並出現錯誤:
Uncaught ReferenceError: _createSaveToDriveWidgetApplication is not defined
我真的不知道還能做什么,因此我在這里查詢。 我已經用谷歌搜索了該錯誤消息,但確實沒有任何關於它的信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.