簡報作業

Google Slides API 可讓您建立簡報檔案及管理現有檔案。 本網頁上的範例顯示一些常見的網頁呈現作業, 這個 presentations.batchUpdate敬上 方法。

這些範例會顯示為中立語言的 HTTP 要求。學習 如何使用 Google API 實作不同語言版本的批次更新 用戶端程式庫,請參閱下列指南:

建立簡報

下列 presentations.create敬上 程式碼範例顯示如何建立標題為「我的新」的空白簡報檔案 簡報」

您也可以使用 Google Drive API 建立空白簡報檔案 files.create 方法,方法是指定 application/vnd.google-apps.presentation 做為 MIME type

以下是建立簡報的要求通訊協定:

POST https://slides.googleapis.com/v1/presentations
{
  "title": "My New Presentation"
}

列出現有的簡報檔案

Slides API 並未提供擷取 但 Drive API 卻提供。 files.list 方法 (如 下方) 會使用欄位遮罩傳回 包括檔案 ID、檔案名稱和 以及用於開啟檔案的連結請求也指定了 採用 application/vnd.google-apps.presentation 做為 MIME 類型

以下是列出現有簡報檔案的要求通訊協定:

GET https://www.googleapis.com/drive/v3/files?q="mimeType=application/vnd.google-apps.presentation"&fields=files(id,name,webViewLink)

回應此內容的回應 要求的結構如下:

{
 "files": [
    {
     "id": "abcdefghijklmnopqrstuvwxyz0123456789",
     "name": "Project Vision",
     "webViewLink": "https://docs.google.com/a/google.com/presentation/d/abcdefghijklmnopqrstuvwxyz0123456789/edit?usp=drivesdk"
    },
    {
     "id": "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
     "name": "Untitled Presentation",
     "webViewLink": "https://docs.google.com/a/google.com/presentation/d/ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/edit?usp=drivesdk"
    },
    ...
  ]
}

取代整份簡報中的文字

下列 presentations.batchUpdate敬上 程式碼範例顯示如何使用 ReplaceAllTextRequest 方法來取代整個簡報中的文字 PRESENTATION_ID。您可以瞭解 簡報 ID

一律輸入「Gizmo Corp」字串,替換成「小工具」的文字 股份有限公司。」這包括文字方塊中的文字、其他形狀、投影片上和內部的文字 主修或主控權在此情況下,文字取代功能會區分大小寫 matchCase敬上 至 true

下列是取代簡報文字的要求通訊協定:

POST https://slides.googleapis.com/v1/presentations/PRESENTATION_ID:batchUpdate
{
  "requests": [
    {
      "replaceAllText": {
          "containsText": {
            "text": "Gizmo Corp.",
            "matchCase": true
          },
          "replaceText": "Gadget Inc."
      }
    }
  ]
}