如何从 Google Apps 脚本发布 Google 幻灯片演示文稿?

How to publish a Google Slides presentation from Google Apps Script?

我使用 Google Apps 脚本构建了 Google 幻灯片演示文稿。

var docId = DriveApp.getFileById(templateId).makeCopy().getId();
var newDoc = DriveApp.getFileById(docId).setName(newDocName);
var newDocUrl = newDoc.getUrl(); // This gets the URL of the editing view. I want the presentation view.

如何发布它然后获取已发布演示文稿的 URL?

Here are the docs. 我正在寻找类似的东西:

var publishedNewDoc = newDoc.publish();
var newDocPublishedUrl = publishedNewDoc.getPublishedUrl();
  • 您想使用脚本发布 Google 个幻灯片。
  • 您想检索已发布的 URL。
  • 您想使用 Google Apps 脚本实现此目的。

如果我的理解是正确的,这个答案怎么样?

发布Google 幻灯片:

要发布 Google 文档,您可以使用 Revisions: update in Drive API 的方法。关于这个,你可以看到作为几个答案之一。

示例脚本:

在您使用此脚本之前,please enable Drive API at Advanced Google services.

var slidesId = "###"; // Please set this.
Drive.Revisions.update({published: true, publishedOutsideDomain: true, publishAuto: true}, slidesId, 1);

检索已发布 URL:

当您手动将 Google 幻灯片发布到网络时,您可以看到 URL 像 https://docs.google.com/presentation/d/e/2PACX-###/pub。不幸的是,在当前阶段,无法检索此 URL。因此,作为解决方法,可以使用文件 ID 检索已发布的 URL。发布的URL,文件id为Google的幻灯片如下。

https://docs.google.com/presentation/d/### file ID ###/pub
  • 如果要使用查询参数,请在上面设置URL。
  • 以上URL没有直接创建的方法,请使用脚本创建。

参考文献:

如果我误解了你的问题,这不是你想要的结果,我深表歉意。