-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreatemeeting.php
124 lines (114 loc) · 4.97 KB
/
createmeeting.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
require_once 'jwt/BeforeValidException.php';
require_once 'jwt/ExpiredException.php';
require_once 'jwt/SignatureInvalidException.php';
require_once 'jwt/JWT.php';
require_once "config.php";
use \Firebase\JWT\JWT;
class Zoom_Api
{
private $zoom_api_key = API_KEY;
private $zoom_api_secret = SECRET_KEY;
protected function sendRequest($data)
{
$request_url = 'https://api.zoom.us/v2/users/me/meetings';
$headers = array(
"authorization: Bearer " . $this->generateJWTKey(),
'content-type: application/json'
);
$postFields = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $request_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$err = curl_error($ch);
curl_close($ch);
if (!$response) {
return $err;
}
return json_decode($response);
}
//function to generate JWT
private function generateJWTKey()
{
$key = $this->zoom_api_key;
$secret = $this->zoom_api_secret;
$token = array(
"iss" => $key,
"exp" => time() + 3600 //60 seconds as suggested
);
return JWT::encode($token, $secret);
}
public function createAMeeting($data = array())
{
$post_time = $data['start_date'];
$start_time = gmdate("Y-m-d\TH:i:s", strtotime($post_time));
$createAMeetingArray = array();
if (!empty($data['alternative_host_ids'])) {
if (count($data['alternative_host_ids']) > 1) {
$alternative_host_ids = implode(",", $data['alternative_host_ids']);
} else {
$alternative_host_ids = $data['alternative_host_ids'][0];
}
}
$createAMeetingArray['topic'] = $data['meetingTopic'];
$createAMeetingArray['agenda'] = !empty($data['agenda']) ? $data['agenda'] : "";
$createAMeetingArray['type'] = !empty($data['type']) ? $data['type'] : 2; //Scheduled
$createAMeetingArray['start_time'] = $start_time;
$createAMeetingArray['timezone'] = $data['timezone'];
$createAMeetingArray['password'] = !empty($data['password']) ? $data['password'] : "";
$createAMeetingArray['duration'] = !empty($data['duration']) ? $data['duration'] : 60;
$createAMeetingArray['settings'] = array(
'join_before_host' => !empty($data['join_before_host']) ? true : false,
'host_video' => !empty($data['option_host_video']) ? true : false,
'participant_video' => !empty($data['option_participants_video']) ? true : false,
'mute_upon_entry' => !empty($data['option_mute_participants']) ? true : false,
'enforce_login' => !empty($data['option_enforce_login']) ? true : false,
'auto_recording' => !empty($data['option_auto_recording']) ? $data['option_auto_recording'] : "none",
'alternative_hosts' => isset($alternative_host_ids) ? $alternative_host_ids : ""
);
return $this->sendRequest($createAMeetingArray);
}
}
// print_r($row);
@session_start();
if (isset($_SESSION['id']) && isset($_SESSION['type'])) {
if ($_SESSION['type'] == 1) {
?>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
</head>
<center>
<h2>CREATE MEETING</h2>
<hr>
<form method="post" action="create_meeting_api.php">
<table>
<tr>
<td>
Topic
</td>
<td>
<input type="text" class="form-control" id="tpoic" name="topic" placeholder="Enter Topic">
</td>
</tr>
<tr>
<td>
<input type="submit" class="btn btn-primary" id="submit" name="submit" value="Create meeting">
</td>
</tr>
</table>
</form>
</center>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/[email protected]/dist/umd/popper.min.js" integrity="sha384-KsvD1yqQ1/1+IA7gi3P0tyJcT3vR+NdBTt13hSJ2lnve8agRGXTTyNaBYmCR/Nwi" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-nsg8ua9HAw1y0W1btsyWgBklPnCUAFLuTMS2G72MMONqmOymq585AcH49TLBQObG" crossorigin="anonymous"></script>
<?php
}
} else {
header('location:login.php', true);
// header('loaction:login.php');
}
?>