【问题标题】:Google Drive Save to Drive ButtonGoogle 云端硬盘保存到云端硬盘按钮
【发布时间】:2015-03-07 09:55:11
【问题描述】:

所以我正在学习 Google 云端硬盘 API 并学习如何在网页中嵌入“保存到云端硬盘”按钮。我安装了 WAMP,并在地址栏中输入以下内容:localhost/gdrive.html

<!DOCTYPE HTML>
<html>
    <script src="https://apis.google.com/js/platform.js"></script>
        <div class="g-savetodrive"
             data-src="http://localhost/test.txt"
             data-filename="test.txt"
             data-sitename="Test document">
        </div>
</html>

gdrive.html 应该将一个名为 test.txt 的文件保存到我的谷歌驱动器(test.txt 位于 WAMP 服务器的 www 文件夹中)。但是,当我登录并点击保存按钮时,它不起作用。它只需要永远(下图中的 Google 驱动器加载图标)。它实际上并没有保存到我的 Google Drive。这是我第一次学习 Google Drive 的 API,这是有原因的吗(是因为 localhost。

【问题讨论】:

    标签: google-drive-api save wamp


    【解决方案1】:

    我没有看到您的客户 ID 列出。您需要确保已下载 Google 提供的库。有两个主要步骤。

    1. 指定您的选项,确保包括您的客户 ID:

    var realtimeOptions = {
      /**
       * Client ID from the console.
       */
      clientId: 'INSERT YOUR CLIENT ID HERE'
      
      /**
       * Add any other options you want.
       */
    }
    1. 初始化实时加载器:

    function startRealtime() {
      var realtimeLoader = new rtclient.RealtimeLoader(realtimeOptions);
      realtimeLoader.start();
    }

    确保包含必要的 Google 库:

    <!-- Load the Realtime libraries. -->
    <script type="text/javascript"
            src="https://apis.google.com/js/api.js"></script>
    
    <!-- Load the utility library. -->
    <script type="text/javascript"
            src="realtime-client-utils.js"></script>

    所有信息都可以在here找到。

    【讨论】:

    • 什么是客户端 ID?
    • 您必须在 Google Developers Console 中设置您的应用程序。您需要的所有信息都在我原始帖子末尾的链接中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多