/** * Creates a Slides API service object and logs the number of slides and * elements in a sample presentation: * https://docs.google.com/presentation/d/1EAYk18WDjIG-zp_0vLm3CsfQh_i8eXc67Jo2O9C6Vuc/edit */functionlogSlidesAndElements(){constpresentationId='1EAYk18WDjIG-zp_0vLm3CsfQh_i8eXc67Jo2O9C6Vuc';try{// Gets the specified presentation using presentationIdconstpresentation=Slides.Presentations.get(presentationId);constslides=presentation.slides;// Print the number of slides and elements in presentationconsole.log('Thepresentationcontains%sslides:',slides.length);for(leti=0;i < slides.length;i++){console.log('-Slide#%scontains%selements.',i+1,slides[i].pageElements.length);}}catch(err){// TODO (developer) - Handle Presentation.get() exception from Slides APIconsole.log('FailedtofoundPresentationwitherror%s',err.message);}}
[null,null,["最后更新时间 (UTC):2024-12-21。"],[[["This quickstart demonstrates how to use Google Apps Script to create a script that interacts with the Google Slides API."],["You will learn how to configure the script, enable the Google Slides API, and run the script to access slide data."],["The provided code sample retrieves and logs the number of slides and elements within a specific Google Slides presentation."],["To run this quickstart, you'll need a Google Account and access to Google Drive."],["For production environments, review authentication and authorization best practices before choosing access credentials for your application."]]],["This content outlines setting up and running a Google Apps Script that interacts with the Google Slides API. Key actions include creating a new script at script.google.com, pasting provided code into the editor, saving and renaming the project, and enabling the Google Slides API as a service. After this, run the script, authorize access, and view the execution log. The provided code retrieves a presentation by ID, and then prints the number of slides and elements.\n"]]