Advanced Google services | Apps Script
文章推薦指數: 80 %
The advanced services in Apps Script let experienced developers connect to certain public Google APIs with less set-up than using their HTTP ... Google AppsScript LearnAppsScript Buildadd-ons UsetheRESTAPI Language English BahasaIndonesia Deutsch Español Français Português–Brasil Русский 中文–简体 日本語 한국어 Signin AutomatetaskswithAppsScript Guides Reference Samples Support Google AppsScript LearnAppsScript Guides Reference Samples Support Buildadd-ons UsetheRESTAPI Overview AppsScriptdashboard Explorethedevelopmentenvironment ScriptprojectsManifestsScopesDeploymentsCloudPlatformprojectsLoggingOAuthclientverificationLibrariesVersionsCollaboration AppsScriptruntimes V8RuntimeoverviewMigratingtotheV8runtime GoogleservicesandexternalAPIs Built-inGoogleservicesAdvancedGoogleservicesAuthorizationExternalAPIs Typesofscripts StandaloneBoundtoGoogleWorkspacedocuments ExtendGoogleWorkspace GoogleDocs GoogleSheets OverviewCustomfunctionsMacrosConnectedSheets GoogleSlides OverviewStructureofapresentationSizingandpositioningpageelementsSelectingitemsinapresentationEditingandstylingtextLifecycleofanupdate Menus,dialogs,andsidebars CustomMenusinGoogleWorkspaceDialogsandsidebarsinGoogleWorkspace Userinterfaces CreateandserveHTMLClient-to-servercommunicationTemplatedHTMLRestrictionsMigratetoIFRAMEWebappsBestpractices Storeandservedata Script,user,anddocumentpropertiesExternaldatabasesviaJDBCContentservice ConvertVBAMacrostoAppsScript OverviewDetermineVBAcompatibilityConvertVBAmacrostoAppsScriptFixconversionerrorsAddresscommonissuesWatchvideotutorialsViewlistofcompatibleVBAAPIs Home GoogleWorkspaceforDevelopers AppsScript LearnAppsScript Sendfeedback AdvancedGoogleservices TheadvancedservicesinAppsScriptletexperienceddevelopersconnectto certainpublicGoogleAPIswithlessset-upthanusingtheirHTTPinterfaces. AdvancedservicesareessentiallythinwrappersaroundthoseGoogleAPIs.They workmuchlikeAppsScript's built-inservices—forexample,theyoffer autocomplete,andAppsScripthandlesthe authorizationflowautomatically. However,youmustenableanadvancedservicebefore youcanuseitinascript. ToseewhichGoogleAPIsareavailableasadvancedservices,lookforthe AdvancedGoogleServicessectioninthe Reference.IfyouwanttouseaGoogleAPIthat isn'tavailableasanadvancedservice,justconnecttoitlikeanyother externalAPI. AdvancedservicesorHTTP? EachoftheadvancedGoogleservicesisassociatedwithapublicGoogleAPI. InAppsScript,youcanaccesstheseAPIsviaadvancedservicesorbysimply makingtheAPIrequestsdirectlyusing UrlFetch. Ifyouusetheadvancedservicemethod,AppsScripthandlesthe authorizationflowandoffers autocompletesupport.However,youmust enabletheadvancedservicebeforeyoucanuse it.Inaddition,someadvancedservicesonlyprovideasubsetofthe functionalityavailableintheAPI. IfyouusetheUrlFetchmethodtoaccesstheAPIdirectly,youare essentiallytreatingtheGoogleAPIasan externalAPI.Withthismethod,all aspectsoftheAPIcanbeused.However,itrequiresyoutohandletheAPI authorizationyourself.Youmustalsoconstructanyneededheadersandparse theAPIresponses. Ingeneralit'seasiesttouseanadvancedservicewherepossibleandonly usetheUrlFetchmethodwhentheadvancedservicedoesn'tprovidethe functionalityyouneed. Requirements Beforeyoucanuseanadvancedservice,youmustsatisfythefollowing requirements: Youmustenabletheadvancedservice inyourscriptproject. YoumustmakesuretheAPIcorrespondingtotheadvancedserviceisenabled intheCloudPlatform(GCP)project yourscriptuses. IfyourscriptprojectusesadefaultGCPproject createdonorafterApril8,2019,theAPIisenabledautomatically afteryouenabletheadvancedserviceandsavethescriptproject.Ifyou havenotdonesoalready,youmayalsobe askedtoagreetotheGoogleCloudPlatform andGoogleAPIsTermsofServiceaswell. Ifyourscriptprojectusesa standardGCPproject oranolderdefaultGCPproject, youmustenabletheadvancedservice'scorrespondingAPI intheGCPprojectmanually.YoumusthaveeditaccesstotheGCPproject tomakethischange. SeeCloudPlatformprojects formoreinformation. Enableadvancedservices TouseanadvancedGoogleservice,followtheseinstructions: Neweditor OpentheAppsScriptproject. Attheleft,clickEditorcode. Attheleft,nexttoServices,clickAddaservice add. SelectanadvancedGoogleserviceandclickAdd. Legacyeditor Inthescripteditor,selectResources>AdvancedGoogleservices.... IntheAdvancedGoogleServicedialogthatappears,clicktheon/off switchnexttotheserviceyouwanttouse. ClickOKinthedialog. Note:Ifyou'reusingastandardGCPproject (oranolderdefaultGCPprojectthatwascreatedpriorto April8,2019),youmustalsomanuallyenabletheAPIcorrespondingtothe advancedservice.EnabletheAPIbydoingthefollowing: OpentheGCPprojectassociatedwithyourscriptinthe GoogleAPIConsole. Atthetopoftheconsole,clickintothesearchbarandtypepartofthenameof theAPI(forexample,"Calendar"),thenclickthenameonceyouseeit. Onthenextscreen,clickEnableAPI. ClosetheAPIConsoleandreturntothescripteditor. ClickOKinthedialog. Afteryouenableanadvancedservice,it'savailableinautocomplete. Howmethodsignaturesaredetermined Advancedservicesgenerallyusethesameobjects,methodnames,andparameters asthecorrespondingpublicAPIs,althoughmethodsignaturesaretranslatedfor useinAppsScript.Thescripteditor's autocompletefunction usuallyprovidesenoughinformationtogetstarted,buttherulesbelowexplain howAppsScriptgeneratesamethodsignaturefromapublicGoogleAPI. RequeststoGoogleAPIscanacceptavarietyofdifferenttypesofdata, includingpathparameters,queryparameters,arequestbody,and/oramedia uploadattachment.SomeadvancedservicescanalsoacceptspecificHTTPrequest headers(forexample,the Calendaradvancedservice). ThecorrespondingmethodsignatureinGoogleAppsScripthasthefollowing arguments: Therequestbody(usuallyaresource),asaJavaScriptobject. Pathorrequiredparameters,asindividualarguments. Themediauploadattachment,asaBlob argument. Optionalparameters,asaJavaScriptobjectmappingparameternamesto values. HTTPrequestheaders,asaJavaScriptobjectmappingheadernamestoheader values. Ifthemethoddoesn'thaveanyitemsinagivencategory,thatpartofthe signatureisomitted. Therearesomespecialexceptionstobeawareof: Formethodsthatacceptamediaupload,theparameteruploadTypeisset automatically. MethodsnameddeleteintheGoogleAPIarenamedremoveinAppsScript, sincedeleteisareservedwordinJavaScript. IfanadvancedserviceisconfiguredtoacceptHTTPrequestheaders,andyou setarequestheadersJavaScriptobject,thenyoumustalsosettheoptional parametersJavaScriptobject(toanemptyobjectifyouaren'tusing optionalparameters). Supportforadvancedservices AdvancedservicesarejustthinwrappersthatenablestheuseofaGoogle APIswithinAppsScript.Assuch,anyissueencounteredwhileusingthemis usuallyanissuewiththeunderlyingAPI,notwithAppsScriptitself. Ifyouencounteraproblemwhileusinganadvancedservice,itshouldbe reportedusingthesupportinstructionsfortheunderlyingAPI.Linkstothese supportinstructionsareprovidedineachadvancedserviceguideinthe AppsScriptReferencesection. Sendfeedback Exceptasotherwisenoted,thecontentofthispageislicensedundertheCreativeCommonsAttribution4.0License,andcodesamplesarelicensedundertheApache2.0License.Fordetails,seetheGoogleDevelopersSitePolicies.JavaisaregisteredtrademarkofOracleand/oritsaffiliates. Lastupdated2021-07-17UTC. [{ "type":"thumb-down", "id":"missingTheInformationINeed", "label":"MissingtheinformationIneed" },{ "type":"thumb-down", "id":"tooComplicatedTooManySteps", "label":"Toocomplicated/toomanysteps" },{ "type":"thumb-down", "id":"outOfDate", "label":"Outofdate" },{ "type":"thumb-down", "id":"samplesCodeIssue", "label":"Samples/codeissue" },{ "type":"thumb-down", "id":"otherDown", "label":"Other" }] [{ "type":"thumb-up", "id":"easyToUnderstand", "label":"Easytounderstand" },{ "type":"thumb-up", "id":"solvedMyProblem", "label":"Solvedmyproblem" },{ "type":"thumb-up", "id":"otherUp", "label":"Other" }] Needtotellusmore? Blog ReadtheGoogleWorkspaceDevelopersblog StackOverflow Askaquestionunderthegoogle-apps-scripttag CodeSamples Exploreourcodesamplesorcopythemtobuildyourown Videos WatchAppsScripttutorials GoogleWorkspaceforDevelopers Platformoverview Developerproducts Developersupport TermsofService Tools AdminConsole AppsScriptDashboard GoogleCloudconsole Connect Blog Newsletter Twitter YouTube Android Chrome Firebase GoogleCloudPlatform Allproducts Terms Privacy SignupfortheGoogleDevelopersnewsletter Subscribe Language English BahasaIndonesia Deutsch Español Français Português–Brasil Русский 中文–简体 日本語 한국어
延伸文章資訊
- 1Advanced Search - Google
- 2Do an Advanced Search on Google - Android
On your Android phone or tablet, go to Advanced Search: google.com/advanced_search. · Under “Find...
- 3Advanced Google Analytics
Advanced Google Analytics walks you through how data gets collected and processed into readable r...
- 415 Google Advanced Search Secrets:Get Expert Practical Skill
Ninja Strategy how to use Google advanced search and get exactly what you want in a few seconds.B...
- 5Advanced Search - Google Patents
Search and read the full text of patents from around the world with Google Patents, and find prio...