كيفية إنشاء اجتماعات Zoom باستخدام Google Script

يصف هذا الدليل كيف يمكنك إنشاء اجتماعات مستخدم برمجيًا في حساب Zoom الخاص بك بمساعدة Google Apps Script وZoom API الرسمي.
كخطوة أولى، انتقل إلى Zoom Developer Dashboard وقم بإنشاء تطبيق جديد. يختار JWT
كنوع التطبيق وقم بتدوين مفتاح Zoom API والسر. يمكننا إنشاء تطبيقات Zoom باستخدام مكتبة OAuth2 أيضًا، ولكن نظرًا لأن هذا التطبيق مخصص للاستخدام الداخلي فقط ولن يتم نشره في سوق Zoom، فإن نهج JWT أسهل.
سيتضمن التطبيق خطوتين. سنقوم بالاتصال بـ /api.zoom.us/v2/users/
API للحصول على معرف Zoom للمستخدم الحالي المصادق عليه. بعد ذلك، نقوم بتقديم طلب POST إلى /v2/users/<<ZoomUserId>>/meetings
نقطة النهاية لإنشاء اجتماع Zoom الفعلي.
قم بإنشاء رمز وصول Zoom
const ZOOM_API_KEY = '<Your Zoom key here>>';
const ZOOM_API_SECRET = '<Your Zoom secret here>';
const ZOOM_EMAIL = '<Your Zoom account email here>';
const getZoomAccessToken = () => {
const encode = (text) => Utilities.base64Encode(text).replace(/=+$/, '');
const header = { alg: 'HS256', typ: 'JWT' };
const encodedHeader = encode(JSON.stringify(header));
const payload = {
iss: ZOOM_API_KEY,
exp: Date.now() + 3600
};
const encodedPayload = encode(JSON.stringify(payload));
const toSign = `${encodedHeader}.${encodedPayload}`;
const signature = encode(Utilities.computeHmacSha256Signature(toSign, ZOOM_API_SECRET));
return `${toSign}.${signature}`;
};
الحصول على معرف المستخدم الداخلي للمستخدم الحالي
const getZoomUserId = () => {
const request = UrlFetchApp.fetch('https://api.zoom.us/v2/users/', {
method: 'GET',
contentType: 'application/json',
headers: { Authorization: `Bearer ${getZoomAccessToken()}` }
});
const { users } = JSON.parse(request.getContentText());
const [{ id } = {}] = users.filter(({ email }) => email === ZOOM_EMAIL);
return id;
};
جدولة اجتماع Zoom
يمكنك إنشاء اجتماع فوري أو جدولة اجتماع لمدة محددة. تم تحديد وقت بدء الاجتماع في yyyy-MM-ddThh:mm:ss
التنسيق مع المنطقة الزمنية المحددة.
القائمة الكاملة لخيارات الاجتماعات متاحة هنا بينما تتوفر المناطق الزمنية هنا.
const createZoomMeeting = () => {
const meetingOptions = {
topic: 'Zoom Meeting created with Google Script',
type: 1,
start_time: '2020-07-30T10:45:00',
duration: 30,
timezone: 'America/New_York',
password: 'labnol',
agenda: 'Discuss the product launch',
settings: {
auto_recording: 'none',
mute_upon_entry: true
}
};
const request = UrlFetchApp.fetch(`https://api.zoom.us/v2/users/${getZoomUserId()}/meetings`, {
method: 'POST',
contentType: 'application/json',
headers: { Authorization: `Bearer ${getZoomAccessToken()}` },
payload: JSON.stringify(meetingOptions)
});
const { join_url, id } = JSON.parse(request.getContentText());
Logger.log(`Zoom meeting ${id} created`, join_url);
};
يمكن تحسين التطبيق لإضافة مشاركين جدد تلقائيًا إلى الاجتماع بعد تسجيل عنوان بريدهم الإلكتروني في نماذج Google، على سبيل المثال. في هذه الحالة، يتم تقديم طلب POST إلى /meetings/{meetingId}/registrants
مع عنوان البريد الإلكتروني والاسم الأول للمشارك في نص الطلب.
اكتشاف المزيد من مرابع التكنولوجيا
اشترك للحصول على أحدث التدوينات المرسلة إلى بريدك الإلكتروني.