如何让共享功能与 gapi 一起使用

How to get share function to work with gapi

我在使用 gapi 的分享功能时遇到错误。

在drive_sdk中打开Url:

http://docswriter.com/#/edit/{ids}

该页面也在谷歌搜索控制台中验证为:

docswriter.com

js中的分享功能:

factory.share = function(fileid) {
        var appid = '***********'; //Using App ID from Drive UI Integration
        var init = function() {
            var s = new gapi.drive.share.ShareClient(appid);
            s.setItemIds([fileid]);
            s.showSettingsDialog();
        }
        gapi.load('drive-share', init);
    };

错误:

Refused to display 'https://drive.google.com/sharing/share?id=10RAw2XV2n3qizC237Z_HoXcbeeWeuEDS…ient=postMessage&appId=***********&embedOrigin=http%3A%2F%2Fdocswriter.com' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

问题已通过在清单文件中使用应用程序 ID 创建 chrome web store listing 解决,如下所示:(应用程序 ID 为 api_console_project_id)

{
  "name": "Docswriter",
  "description": "App to write documentation",
  "version": "0.0.0.2",
  "manifest_version": 2,
  "api_console_project_id" : "4********3",
  "icons": {
    "128": "icon_128.png"
  },
  "app": {
    "urls": [
      "http://docswriter.com/"
    ],
    "launch": {
      "web_url": "http://docswriter.com/"
    }
  }
}

当我从 chrome 网上商店安装应用程序时,它起作用了。