Google云端硬盘保存到云端硬盘按钮

时间:2015-03-07 01:19:17

标签: google-drive-api save wamp

因此,我正在学习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的文件保存到我的google驱动器中(test.txt位于WAMP服务器的www文件夹中)。但是,当我登录并点击“保存”按钮时,它不起作用。它只需要永远(下图中的Google驱动器加载图标)。它实际上并没有保存到我的Google云端硬盘。这是我第一次学习Google Drive的API,并且之所以出现这种情况(是因为localhost。

1 个答案:

答案 0 :(得分:0)

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

  1. 指定您的选项,确保包含您的客户ID:
  2. var realtimeOptions = {
      /**
       * Client ID from the console.
       */
      clientId: 'INSERT YOUR CLIENT ID HERE'
      
      /**
       * Add any other options you want.
       */
    }

    1. 初始化Realtime Loader:
    2. 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

相关问题