Trouble integrating REST API

Hi there,

I am getting some issues while integrating the rest api, like how to call the sendRequest function from the button that is there in the html form…

Hi Mahesh,

please take a look at Zoom’s document @ https://zoom.us/developer/overview/getting-started-with-rest-api.

You can also try to call REST API using postman.

Best

Hi Wei,

Well I had tried to do the same with the POSTMAN also but the response is coming as the error:300, The screenshots are attached below. And while implementing the REST API in PHP, I am not getting any response from the server. I want to get the output by using the PHP only, I don’t need any other vendor to get the response.

Thanks.

Hi Mahesh, see the discussion on the same topic here - 

https://support.zoom.us/hc/en-us/community/posts/115017694543-Post-request-keeps-asking-me-Api-Key-and-secret-are-required-

can you check if you are including all parameters in the URL ? this quick php example might be helpful 

https://github.com/zoomvideo/PHP/blob/master/ZoomRESTAPIPHP.php

Regards, Wei @ Zoom

Hey Wei,

Thanks for your suggestion about the POSTMAN and I’ll definitely look at this, but the main issue is with the PHP Api call. I am sending you my code that i had implemented just to create a meeting but the issue is that how the createAMeeting() function which is defined under the class is to be called by using the HTML button which is there in another file. Let me send you the code of the PHP file and HTML file.

 

New.php:

<?php

p1 = _POST[‘host’];
p2 = _POST[‘topic’];
p3 = _POST[‘type’];
/*echo $p1;
echo $p2;
echo $p3;
*/
class Zoom{

private $API_KEY = ‘xxxxxxxxx’;
private $Secret_KEY = ‘xxxxxxxxxx’;
private $url = ‘https://api.zoom.us/v1/’;

//function to redirect the page to Zoom
function sendReq($calledFunction, $data){

//url that will create the endpoint i.e create meeting
$request_url = $this->$url.$calledFunction;

$data[‘api_key’] = $this->$API_KEY;
$data[‘api_secret’] = $this->$Secret_KEY;
$data[‘data_type’] = ‘JSON’;

$postFields = http_build_query($data);
echo $postFields;

$ch = curl_init();
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);

$errorMessage = curl_exec($ch);
echo $errorMessage;
curl_close($ch);

echo $request_url;
var_dump($data);
var_dump($response);
if(!$response){
return false;
}

return json_encode($response);

}

function createAMeeting(){
$createAMeetingArray = array();
$createAMeetingArray[‘host_id’] = $p1;
$createAMeetingArray[‘topic’] = $p2;
$createAMeetingArray[‘type’] = $p3;
return $this->sendRequest(‘meeting/create’, $createAMeetingArray);
}
}
?>

 

 

index.html

 

<html>
<head>
<title></title>

</head>
<body>

<form action=“new.php” method=“POST”>
<input type=“text” id=“topic” placeholder=“enter the host id” name=“host”>
<br/><input type=“text” placeholder=“enter the topic” name=“topic”><br/>
<input type=“text” placeholder="enter the type " name=“type”><br/>
<input type=“submit” value=“Create the meeting” name=“createMeeting”>

</form>

</body>

</html>

These two files are there and I had understood the functionality that is happening in the PHP file but the issues comes for the method call using the button in the HTML.

 

Hi Mahesh,

Based on my understanding, this is a general question not related to Zoom REST API functionality. Please do some search. Feel free to contact us if any Zoom REST API functionality is not working.

Best

Wei 

Hi Wei,

Well I had fixed the above issues but when i am trying to create the meeting using the createAMeeting() the error comes for the User not exist. The screenshot is attached below.

Hi Mahesh,

could you check the host ID you passed? You could get it from API function: user/getbyemail.

Best

Wei

Hi Wei,

I am done with the REST API, It is working fine. Thanks for your support and if i get any issues again then I’ll get back to you.

Thanks