【问题标题】:How to publish a Google Slides presentation from Google Apps Script?如何从 Google Apps 脚本发布 Google 幻灯片演示文稿?
【发布时间】:2020-03-19 17:03:29
【问题描述】:

我已经使用 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-apps-script google-slides-api google-slides


    【解决方案1】:
    • 您想使用脚本发布 Google 幻灯片。
    • 您要检索已发布的 URL。
    • 您希望使用 Google Apps 脚本实现此目的。

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

    发布 Google 幻灯片:

    为了发布 Google Docs,您可以使用 Revisions: update in Drive API 的方法。关于这一点,您可以将a sample script 视为几个答案之一。

    示例脚本:

    在你使用这个脚本之前,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 幻灯片发布到网络时,您会看到类似 https://docs.google.com/presentation/d/e/2PACX-###/pub 的 URL。不幸的是,在当前阶段,无法检索此 URL。因此,作为一种解决方法,可以使用文件 ID 检索已发布的 URL。已发布的带有 Google 幻灯片文件 ID 的 URL 如下。

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

    参考资料:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多