@חיידר
תפתח גיליון חדש ותנסה את זה
function doGet(e) {
const sheetName = "נתונים";
const ss = SpreadsheetApp.getActiveSpreadsheet();
let sheet = ss.getSheetByName(sheetName);
// בדיקה אם הגיליון קיים, ואם לא - יצירה והגדרת כותרות
if (!sheet) {
sheet = ss.insertSheet(sheetName);
const headers = ["תאריך ושעה", "טלפון", "שם", "שלוחה", "שם קובץ (what)", "מיקום עצירה (PlayStop)", "מקש (PressKey)"];
sheet.appendRow(headers);
sheet.getRange(1, 1, 1, headers.length).setFontWeight("bold"); // הדגשת הכותרות
}
const tz = "Asia/Jerusalem";
const now = new Date();
const timeNow = Utilities.formatDate(now, tz, "HH:mm dd/MM/yyyy");
// קליטת פרמטרים ממודול API
const ApiPhone = e.parameter.ApiPhone || "";
const ApiName = e.parameter.ApiName || "";
const ApiExtension = e.parameter.ApiExtension || "";
const what = e.parameter.what || "";
const PlayStop = e.parameter.PlayStop || "";
const PressKey = e.parameter.PressKey || "";
try {
// הוספת הנתונים לגיליון
sheet.appendRow([
timeNow,
ApiPhone,
ApiName,
ApiExtension,
what,
PlayStop,
PressKey
]);
// תשובה למערכת: חזרה לנקודת העצירה (noop)
return ContentService.createTextOutput("read=t-noop").setMimeType(ContentService.MimeType.TEXT);
} catch (err) {
// במקרה של שגיאה בלתי צפויה, החזרת פקודה שתמנע תקיעה של המאזין
return ContentService.createTextOutput("read=t-noop").setMimeType(ContentService.MimeType.TEXT);
}
}