I use Zoom API to create a meeting on my Employee Management System that I created. I’m planning to add a recurrence meeting, and a waiting room. This is my code, here I’m using OAuth
<?php
require_once 'config.php';
function create_meeting($nama_event, $start_time, $password) {
$client = new GuzzleHttp\Client(['base_uri' => 'https://api.zoom.us']);
$db = new DB();
$arr_token = $db->get_access_token();
$accessToken = $arr_token->access_token;
try {
$response = $client->request('POST', '/v2/users/me/meetings', [
"headers" => [
"Authorization" => "Bearer $accessToken"
],
'json' => [
"topic" => "$nama_event",
"start_time" => "$start_time",
"timezone" => "Asia/Jakarta",
"waiting_room" => true,
"password" => "123456",
"recurrence" => [
"end_date_time" => "2022-04-02T15:59:00Z",
"end_times" => 7,
"monthly_day" => 1,
"monthly_week" => 1,
"monthly_week_day" => 1,
"repeat_interval" => 1,
"type" => 2,
"weekly_days" => "1"
]
],
]);
$data = json_decode($response->getBody());
return $data;
// echo "Join URL: ". $data->join_url;
// echo "<br>";
// echo "Meeting Password: ". $data->password;
} catch(Exception $e) {
if( 401 == $e->getCode() ) {
$refresh_token = $db->get_refersh_token();
$client = new GuzzleHttp\Client(['base_uri' => 'https://zoom.us']);
$response = $client->request('POST', '/oauth/token', [
"headers" => [
"Authorization" => "Basic ". base64_encode(CLIENT_ID.':'.CLIENT_SECRET)
],
'form_params' => [
"grant_type" => "refresh_token",
"refresh_token" => $refresh_token
],
]);
$db->update_access_token($response->getBody());
create_meeting($nama_event, $start_time, $password);
} else {
echo $e->getMessage();
}
}
}