Google スライド: スライドページ ID 取得 (Google Slides: Get Slide Page Ids)
指定ファイルのスライドページのIDを文字型データ項目(複数行)に格納します。
Configs
  • U: HTTP認証設定を選択してください *
  • A: Drive内でのファイルID(FILE-ID)をセットしてください *#{EL}
  • D: スライドのページのIDが格納される文字列型データ項目を選択してください(更新)
Script (click to open)
// GraalJS Script (engine type: 2)

//////// START "main()" /////////////////////////////////////////////////////////////////

main();
function main(){ 

//// == Config Retrieving / 工程コンフィグの参照 ==
const strAuthzSetting     = configs.get      ( "AuthzConfU" );   /// REQUIRED
  engine.log( " AutomatedTask Config: Authz Setting: " + strAuthzSetting );
const strInputfileId      = configs.get      ( "StrConfA" );    /// REQUIRED
  if( strInputfileId    === "" ){
    throw new Error( "\n AutomatedTask ConfigError:" +
                     " Config {A1: FileID} is empty \n" );
  }

//// == Calculating / 演算 ==

/// Get FileTitle (and LastPageID)
/// Google Slides API
/// https://developers.google.com/slides/reference/rest/v1/presentations/get
// request0, prepare
let request0Uri = "https://slides.googleapis.com/v1/presentations/" + strInputfileId;
let request0    = httpClient.begin(); // HttpRequestWrapper
    request0    = request0.authSetting( strAuthzSetting ); // with "Authorization: Bearer XX"
    // https://questetra.zendesk.com/hc/en-us/articles/360024574471-R2300#HttpRequestWrapper

// request0, try
const response0 = request0.get( request0Uri ); // HttpResponseWrapper
engine.log( " AutomatedTask ApiRequest0 Start: " + request0Uri );
const response0Code = response0.getStatusCode() + "";
const response0Body = response0.getResponseAsString() + "";
engine.log( " AutomatedTask ApiResponse Status: " + response0Code );
if( response0Code !== "200"){
  throw new Error( "\n AutomatedTask UnexpectedResponseError: " +
                    response0Code + "\n" + response0Body + "\n" );
}

// response0, parse
/* 
engine.log( response0Body ); // debug
{
  "presentationId": "1MsdTWR_pN4FQTCCqUhC1F_JWWsagogISvPF9WqOmaq8",
  "pageSize": { ## },
  "slides": [
    {
      "objectId": "p",
      "pageElements": [ ## ],
      "slideProperties": { ## },
      "pageProperties": { ## }
    },
    {
      "objectId": "g6251321494_0_0",
      "pageElements": [ ## ],
      "slideProperties": { ## },
      "pageProperties": { ## }
    },
    {
      "objectId": "SLIDES_API66619114_0",
      "pageElements": [ ## ],
      "slideProperties": { ## },
      "pageProperties": { ## }
    }
  ],
  "title": "Revenue Report Example",
  "masters": [ ## ],
  "layouts": [ ## ],
  "locale": "ja",
  "revisionId": "bvHyj2SJ0wwg4A",
  "notesMaster": { ## }
}
*/
const response0Obj = JSON.parse( response0Body );
engine.log( " AutomatedTask ApiResponse File Title: " + response0Obj.title );

let objectIds = "";
for (i = 0; i < response0Obj.slides.length; i++) {
  objectIds += response0Obj.slides[i].objectId + "\n";
}

//engine.log(objectIds);
const strIds = configs.getObject( "StrConfB" );
if( strIds !== null ){
  engine.setData( strIds, objectIds );
}

} //////// END "main()" /////////////////////////////////////////////////////////////////


Download

2021-11-11 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/ja/addons/google-slides-get-page-ids/
Addonファイルのインポートは Professional でのみご利用いただけます
自由改変可能な JavaScript (ECMAScript) コードです。いかなる保証もありません。

Capture

Appendix

%d人のブロガーが「いいね」をつけました。