EIOS/zoom.php

308 lines
9.9 KiB
PHP
Raw Normal View History

2023-12-28 15:39:22 +03:00
<?php
date_default_timezone_set('Europe/Moscow');
//exit();
//основная статья как создавать https://infostart.ru/1c/articles/1219405/
$API['key'] = 'YGOGXno3S0SgAhUWcGqAOg';
$API['secret'] = 'F6d9Rh2HqIwCPRzfttsFD4oc5MmzvQmUbsDF';
$API['url'] = 'https://api.zoom.us/v2/';
//создается на странице и указан до 00:00 01.12.2021
//https://marketplace.zoom.us/develop/apps/-htyF97GSnyGubyteTntJQ/credentials
$API['JWTToken'] = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOm51bGwsImlzcyI6IllHT0dYbm8zUzBTZ0FoVVdjR3FBT2ciLCJleHAiOjE2MzgzMDYwMDAsImlhdCI6MTYwMTQ0NDc5Nn0.Iac1qHoPZLOdXggQMHNKYfj_oWpvxZ3-dklxv2Z6GUY';
//отслеживание логов https://marketplace.zoom.us/user/logs?type=api
//инструкция по API
//отобразить все меропритяия https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetings
//создать мероприятие https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingcreate
//и т.д.
$users = zoom_getUsers();
//echo '<pre>'.print_r($users,1).'</pre>';
echo '<!DOCTYPE html>
<html lang="en">
<head>
<title>ZOOM создание мероприятий</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<style>
table{ border-collapse: collapse;}
th{ font-size:18px; font-weight:bold; padding:2px; border:2px solid gray; }
td{ font-size:14px; padding:2px; border:1px solid gray; }
</style>
</head>';
echo '<table>
<tr>
<td>Пользователь</td>
<td>'.$users[0]['first_name'].' '.$users[0]['last_name'].'</td>
</tr>
</table>';
$des = 'view';
if(isset($_GET['des'])) $des = $_GET['des'];
if(isset($_POST['meetingcreate'])){
//Создание мероприятия
$start_time = strtotime($_POST['start_time'])-(60*60*3);//на сервере время +3
$param = array(
'topic'=>$_POST['topic'],
'type'=>2,
'start_time'=>date('Y',$start_time).'-'.date('m',$start_time).'-'.date('d',$start_time).'T'.date('H',$start_time).':'.date('i',$start_time).':00Z',
'duration'=>$_POST['duration'],
'timezone'=>"Europe/Moscow",
'password'=>$_POST['password']
);
$meeting = zoom_meetingCreate($users[0],$param);
//echo '<pre>'.print_r($meeting,1).'</pre>';
$des='view';
}
if($des=='meetingcreate'){
echo '<h2>Создание мероприятия</h2>';
echo '<form method="POST">
<table>
<tr><td>Название</td><td><input type="TEXT" name="topic" value=""></td></tr>
<tr><td>Время начала</td><td><input type="TEXT" name="start_time" value="'.date('H:i d.m.Y').'"></td></tr>
<tr><td>Длительность</td><td><input type="TEXT" name="duration" value="90"></td></tr>
<tr><td>Пароль</td><td><input type="TEXT" name="password" value="" placeholder="не более 10 символов [a-zA-Z0-9+!_]"></td></tr>
<tr><td></td><td><input type="SUBMIT" name="meetingcreate" value="Создать"></td></tr>
</table>
</form>';
}
if($des=='view'){
$meetings = zoom_meetingList($users[0]);
//echo '<pre>'.print_r($meetings,1).'</pre>';
echo '<h2>Запланированные мероприятия</h2>';
echo '<table>
<tr>
<th>Время</th>
<th>Название</th>
<th>ID</th>
<th>Пароль</th>
<th>Ссылка для управления</th>
<th>Ссылка для подключения</th>
<th><a href="/zoom.php?des=meetingcreate">Создать</a></th>
</tr>';
foreach($meetings['meetings'] as $key => $val){
$start_time = strtotime($val['start_time']);
$meet = getMeeting($val['uuid']);
echo '<tr>
<td>'.date('H:i d.m.Y',$start_time).'</td>
<td>'.$val['topic'].'</td>
<td>'.$meet['id'].'</td>
<td>'.$meet['password'].'</td>
<td><a href="'.$meet['start_url'].'" target="_blank">Перейти</a></td>
<td><a href="'.$val['join_url'].'" target="_blank">'.$val['join_url'].'</a></td>
<td>длит: '.$val['duration'].'мин.</td>
</tr>';
}
echo '</table>';
}
function getMeeting($uuid){
$file = 'zoom/'.$uuid.'.json';
if(file_exists($file)){
return json_decode(file_get_contents($file) ,1);
}else{
return array();
}
}
function zoom_meetingList($user){//Просмотр мероприятий
$out = array();
$out['err']=1;
$url = 'users/'.$user['id'].'/meetings';
$rez = zoom_curl($url);
/*
Array
(
[err] => 0
[msg] => cURL Ok
[response] => {
"page_size":30,
"total_records":2,
"next_page_token":"",
"meetings":[
{
"uuid":"+G+izsejS26d7QmpzpbWqA==",
"id":76902907580,
"host_id":"MgQ_chc0Sx2aGLK2eq-_-w",
"topic":"первое мероприятие 1",
"type":2,
"start_time":"2020-09-30T13:30:00Z",
"duration":40,
"timezone":"Europe/Moscow",
"created_at":"2020-09-30T07:13:46Z",
"join_url":"https://us04web.zoom.us/j/76902907580?pwd=clUrV0NBcmRyd3RFbmUwRTM3WVJqUT09"
},
{
"uuid":"Uc0NFgdTSle3zZ4OgM4BOw==",
"id":71451895771,
"host_id":"MgQ_chc0Sx2aGLK2eq-_-w",
"topic":"первое мероприятие 1",
"type":2,
"start_time":"2020-09-30T13:30:00Z",
"duration":40,
"timezone":"Europe/Moscow",
"created_at":"2020-09-30T07:13:18Z",
"join_url":"https://us04web.zoom.us/j/71451895771?pwd=NThieHAyRG9CcmR1NTBVZkFheDhjUT09"
}]
}
)
*/
if($rez['err']==0){
$out['err']=0;
$json = json_decode($rez['response'],1);
$out['meetings'] = $json['meetings'];
}
return $out;
}
function zoom_meetingCreate($user,$param=array()){//Создание мероприятия от пользователя
GLOBAL $API; $out = array();
$out['err']=1;
$url = 'users/'.$user['id'].'/meetings';
if(!count($param)){
$post = array(
'topic'=>"первое мероприятие 1",
'type'=>2,
'start_time'=>"2020-09-30T13:30:00Z",
'duration'=>40,
'timezone'=>"Europe/Moscow",
'password'=>"ASD123_rf$"
);
}else{
$post = $param;
}
$rez = zoom_curl($url,$post);
if($rez['err']==0){
$json = json_decode($rez['response'],1);
if(isset($json['uuid'])){
$out['err']=0;
$out['meeting']=$json;
file_put_contents('zoom/'.$json['uuid'].'.json',json_encode($json));
/*Array(
[uuid] => +G+izsejS26d7QmpzpbWqA==
[id] => 76902907580
[host_id] => MgQ_chc0Sx2aGLK2eq-_-w
[host_email] => alneo.ru@yandex.ru
[topic] => первое мероприятие 1
[type] => 2
[status] => waiting
[start_time] => 2020-09-30T13:30:00Z
[duration] => 40
[timezone] => Europe/Moscow
[created_at] => 2020-09-30T07:13:46Z
[start_url] => https://us04web.zoom.us/s/76902907580?zak=eyJ6bV9za20iOiJ6bV9vMm0iLCJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjbGllbnQiLCJ1aWQiOiJNZ1FfY2hjMFN4MmFHTEsyZXEtXy13IiwiaXNzIjoid2ViIiwic3R5IjoxMDAsIndjZCI6InVzMDQiLCJjbHQiOjAsInN0ayI6ImJ2NFItZXA3UVliMU5sRGJrbDU4VndzVERNbjR3Uk9KZDd0aktRNVhyOU0uQmdVZ1lVTmFiRGRDV1hWSFl6TlhUMEZ0ZFhBM1JuZDNUeXRRYm0xNFpteHNlVlpBWldRMk1qWTFaRFV4WXpZMlpESXdNRFkyTVdabE5Ea3hNVEk0WVRNMlpqZzFaREZoWVRVMU5UVTVOekF5TVdNME9XWXdabUZsTlRSbFpUSmhabVE1WkFBZ1dqUjFVblJzTnpOdFZVNTBPR2hIZUVWbVRGSTViblZTWnpWSWJqSmpaVk1BQkhWek1EUSIsImV4cCI6MTYwMTQ1NzIyNiwiaWF0IjoxNjAxNDUwMDI2LCJhaWQiOiI5VGM4bHg5RFNmTy1jaHAyWm56ZXNnIiwiY2lkIjoiIn0.VI3DbA9Hqu5QOSskA6e9Sxk0yKuIHh4IAC4QjohIT9Q
[join_url] => https://us04web.zoom.us/j/76902907580?pwd=clUrV0NBcmRyd3RFbmUwRTM3WVJqUT09
[password] => ASD123_rf$
[h323_password] => 0197207734
[pstn_password] => 0197207734
[encrypted_password] => clUrV0NBcmRyd3RFbmUwRTM3WVJqUT09
[settings] => Array(
[host_video] =>
[participant_video] =>
[cn_meeting] =>
[in_meeting] =>
[join_before_host] =>
[mute_upon_entry] =>
[watermark] =>
[use_pmi] =>
[approval_type] => 2
[audio] => voip
[auto_recording] => none
[enforce_login] =>
[enforce_login_domains] =>
[alternative_hosts] =>
[close_registration] =>
[registrants_confirmation_email] => 1
[waiting_room] => 1
[request_permission_to_unmute_participants] =>
[registrants_email_notification] => 1
[meeting_authentication] =>
)
)
*/
}
}
return $out;
}
function zoom_getUsers(){//Получение списка пользователей
$users = array();
$url = 'users?status=active&page_size=30&page_number=1';
$rez = zoom_curl($url);
if($rez['err']==0){
$json = json_decode($rez['response'],1);
$users = $json['users'];
}
return $users;
/*echo '<pre>'.print_r($rez,1).'</pre>';
Array(
[err] => 0
[msg] => cURL Ok
[response] => {
"page_count":1,
"page_number":1,
"page_size":30,
"total_records":1,
"users":[
{
"id":"MgQ_chc0Sx2aGLK2eq-_-w",
"first_name":"Alexander",
"last_name":"Yakov",
"email":"alneo.ru@yandex.ru",
"type":1,
"pmi":5136867612,
"timezone":"Europe/Moscow",
"verified":1,
"dept":"",
"created_at":"2020-04-14T07:35:53Z",
"last_login_time":"2020-09-30T05:35:42Z",
"last_client_version":"5.0.24050.0510(android)",
"language":"ru-RU",
"phone_number":"",
"status":"active"
}
]
}
)
*/
}
function zoom_curl($url,$post=array()){
GLOBAL $API; $out = array();
$curl = curl_init();
$option = array(
CURLOPT_URL => $API['url'].$url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_HTTPHEADER => array(
"authorization: Bearer ".$API['JWTToken'],
"content-type: application/json"
),
);
if(count($post)){
$option[CURLOPT_CUSTOMREQUEST] = 'POST';
$option[CURLOPT_POSTFIELDS] = json_encode($post);
}else{
$option[CURLOPT_CUSTOMREQUEST] = 'GET';
}
curl_setopt_array($curl, $option);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
$out['err']=1;
$out['msg']='cURL Error #:' . $err;
} else {
$out['err']=0;
$out['msg']='cURL Ok';
$out['response']=$response;
}
return $out;
}