Below is the request body that I’m using for zoom api call.
function customZoom_webform_submission_insert($node, $submission) {
module_load_include('inc', 'webform', 'includes/webform.submissions');
$submissions = webform_get_submissions(array('nid'=> 34501));
$timeData = [];
foreach ($submissions as $submission){
foreach ($submission->data as $row=>$data){
$timeData[$submission->sid][$row] = $data[0];
}
foreach ($timeData as $value) {
# code...
$topic = $value['1'];
$type = 2;
$date = $value['2'];
$time = $value['3'];
$start_time = $date."T".$time;
$duration = $value['9'];
$userid = $value['10'];
$timezone = $value['5'];
$host_video = $value['6'];
$participant_video = $value['7'];
$audio = $value['8'];
}
}
if (isset($_SESSION["counter"]) && $_SESSION["counter"] > 0 ){
unset($_SESSION["counter"]);
}else{
$_SESSION["counter"] = 1;
$key = "{{ key }}";
$payload = array(
"iss" => "CDfctbTdRk6kQFLFFb32pw",
"iat" => time(),
"exp" => time()+5000
);
$token = JWT::encode($payload, $key);
$curl = curl_init();
$post_data = array(
'topic' =>$topic,
'type' => 2,
'start_time'=>$start_time,
'duration'=>$duration,
'timezone'=>$timezone,
'password'=>"{{ password }}",
'agenda'=>"",
'settings'=>array(
'host_video'=>$host_video,
'participant_video'=>$participant_video,
'cn_meeting'=>false,
'in_meeting'=>false,
'join_before_host'=>false,
'mute_upon_entry'=>false,
'watermark'=>false,
'use_pmi'=>false,
'approval_type'=>2,
'registration_type'=>1,
'audio'=>$audio,
'auto_recording'=>"none",
'enforce_login'=>true,
'enforce_login_domains'=>"",
'alternative_hosts'=>""
)
);
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.zoom.us/v2/users/$userid/meetings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 1000,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode($post_data),
CURLOPT_HTTPHEADER => array(
"authorization: Bearer $token",
"content-type: application/json"
),
));
$res1 = curl_exec($curl);
//print_r($res1);
//die('test');
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
$result1 = json_decode($res1,true);
$output = array(
'#theme' => 'customZoom_create_meetings_template',
'#type' => 'markup',
'#result1'=>$result1,
);
return $output;
}
}
Also I’m using JWT .