توضّح عمليات الإعداد السريع كيفية إعداد تطبيق يستدعي واجهة برمجة التطبيقات
Google Workspace API وتشغيله.
تستخدِم عمليات الإعداد السريع في Google Workspace مكتبات عملاء واجهة برمجة التطبيقات لمعالجة بعض
تفاصيل عملية المصادقة والتفويض. ننصحك باستخدام مكتبات العملاء لتطبيقاتك. يستخدم دليل البدء السريع هذا أسلوب مصادقة بسيطًا ومناسبًا لبيئة الاختبار. بالنسبة إلى بيئة الإنتاج، ننصحك بالاطّلاع على معلومات عن
المصادقة والتفويض
قبل
اختيار بيانات اعتماد الوصول
الملائمة لتطبيقك.
/** * Creates a Sheets API service object and prints the names and majors of * students in a sample spreadsheet: * https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit * @see https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/get */functionlogNamesAndMajors(){constspreadsheetId='1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms';constrangeName='ClassData!A2:E';try{// Get the values from the spreadsheet using spreadsheetId and range.constvalues=Sheets.Spreadsheets.Values.get(spreadsheetId,rangeName).values;// Print the values from spreadsheet if values are available.if(!values){console.log('Nodatafound.');return;}console.log('Name,Major:');for(constrowinvalues){// Print columns A and E, which correspond to indices 0 and 4.console.log('-%s,%s',values[row][0],values[row][4]);}}catch(err){// TODO (developer) - Handle Values.get() exception from Sheet APIconsole.log(err.message);}}
انقر على رمز الحفظ .
انقر على مشروع بلا عنوان، واكتب
البدء السريع، ثم انقر على إعادة التسمية.
ضبط النص البرمجي
تفعيل Google Sheets API
افتح مشروع Apps Script.
انقر على رمز أداة التعديلcode.
بجانب الخدمات، انقر على رمز إضافة خدمة
add .
اختَر
Sheets API
وانقر على إضافة.
تشغيل العيّنة
في محرِّر Apps Script، انقر على تشغيل.
في المرة الأولى التي تُشغِّل فيها العيّنة، سيُطلَب منك تفويض الوصول:
تاريخ التعديل الأخير: 2024-12-21 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2024-12-21 (حسب التوقيت العالمي المتفَّق عليه)"],[[["This quickstart demonstrates how to use Google Apps Script to connect to and retrieve data from the Google Sheets API."],["You will need a Google Account and access to Google Drive to complete the setup."],["The process involves creating a script, enabling the Google Sheets API, and authorizing access for the script to interact with your spreadsheets."],["Upon successful execution, the script will print data from a sample spreadsheet to the execution log."],["For production environments, further exploration of authentication, authorization, and credential management is recommended."]]],["This document outlines setting up and running a Google Apps Script that interacts with the Google Sheets API. Key actions include: configuring the environment, creating a script, enabling the Sheets API service, and running the script. The script accesses a sample spreadsheet, retrieves student names and majors, and logs them. Authentication authorization is required initially. Client libraries for API are recommended. It also provides links for advanced learning, troubleshooting and bug reporting.\n"]]