Sample REST API via PHP Follow

Update: Please see our Developer Portal for more up to date content on our REST API and Mobile SDK.


REST API should be called from Server side instead of Client side. The following will be an example of setting up a class called "ZoomAPI" in which you can create a REST API call. This will be a basic class that can be built upon for future calls. Please note that this is pseudo-code there may be minor errors.

The example below can be downloaded here.

ZoomAPI Class

The class below will be used in this example for all API calls. The function "sendRequest" will send the HTTP POST to make the API Call. This will then return the information requested. Please note some API calls will be missing.

/*Copyright ©2015 Zoom Video Communications, Inc*/
/*Zoom Support*/

class ZoomAPI{

/*The API Key, Secret, & URL will be used in every function.*/
private $api_key = 'Please Input Your Own API Key Here';
private $api_secret = 'Please Input Your Own API Secret Here';
private $api_url = '';

/*Function to send HTTP POST Requests*/
/*Used by every function below to make HTTP POST call*/
function sendRequest($calledFunction, $data){
	/*Creates the endpoint URL*/
	$request_url = $this->api_url.$calledFunction;

	/*Adds the Key, Secret, & Datatype to the passed array*/
	$data['api_key'] = $this->api_key;
	$data['api_secret'] = $this->api_secret;
	$data['data_type'] = 'JSON';

	$postFields = http_build_query($data);
	/*Check to see queried fields*/
	/*Used for troubleshooting/debugging*/
	echo $postFields;

	/*Preparing Query...*/
	$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);

	/*Check for any errors*/
	$errorMessage = curl_exec($ch);
	echo $errorMessage;

	/*Will print back the response from the call*/
	/*Used for troubleshooting/debugging		*/
	echo $request_url;
		return false;
	/*Return the data in JSON format*/
	return json_encode($response);
/*Functions for management of users*/
function createAUser(){...}
function autoCreateAUser(){...}
function custCreateAUser(){...}
function deleteAUser(){...}
function listUsers(){...}
function listPendingUsers(){...}
function getUserInfo(){...}
function getUserInfoByEmail(){...}
function updateUserInfo(){...}
function updateUserPassword(){...}
function setUserAssistant(){...}
function deleteUserAssistant(){...}
function revokeSSOToken(){...}
function deleteUserPermanently(){...}

/*Functions for management of meetings*/
function createAMeeting(){...}
function deleteAMeeting(){...}
function listMeetings(){...}
function getMeetingInfo(){...}
function updateMeetingInfo(){...} function endAMeeting(){...} function listRecording(){...} /*Functions for management of reports*/ function getDailyReport(){...} function getAccountReport(){...} function getUserReport(){...} /*Functions for management of webinars*/ function createAWebinar(){...} function deleteAWebinar(){...} function listWebinars(){...} function getWebinarInfo(){...} function updateWebinarInfo(){...} function endAWebinar(){...} } ?>

For the following examples, we will assume all requests are being made with a simple form field. That is, all parameters will be passed through with the PHP variable. Please note there are three ways to use pass through data via $_POST. We recommend not using JavaScript as this will allow users to see your API Key & Secret.

  1. With an HTML Form

    <form action="APICall()" method="post">
      <input type="text" name="email" value="" />
      <input type="submit" value="submit" />
  2. Directly through PHP
    $APIContext = stream_context_create(array(
        'http' => array(
          'method'  => 'POST',
          'header'  => "Content-type: text/html\r\n",
          'content' => http_build_query(array('email' => ''))
    $return = APICall(); 
  3. Via AJAX(jQuery(JavaScript))
    $.post('APICall()', {email: ''}, function(data) {

User API Example Calls

For information on all possible parameters and expected response, please see the REST User API documentation.

Create A User

function createAUser(){
  $createAUserArray = array();
  $createAUserArray['email'] = $_POST['userEmail'];
  $createAUserArray['type'] = $_POST['userType'];
  return $this->sendRequest('user/create', $createAUserArray);

Auto-Create A User

function autoCreateAUser(){
  $autoCreateAUserArray = array();
  $autoCreateAUserArray['email'] = $_POST['userEmail'];
  $autoCreateAUserArray['type'] = $_POST['userType'];
  $autoCreateAUserArray['password'] = $_POST['userPassword'];
  return $this->sendRequest('user/autocreate', $autoCreateAUserArray);

Cust-Create A User

function custCreateAUser(){
  $custCreateAUserArray = array();
  $custCreateAUserArray['email'] = $_POST['userEmail'];
  $custCreateAUserArray['type'] = $_POST['userType'];
  return $this->sendRequest('user/custcreate', $custCreateAUserArray);

Delete A User

function deleteAUser(){
  $deleteAUserArray = array();
  $deleteAUserArray['id'] = $_POST['userId'];
  return $this->sendRequest('user/delete', $deleteUserArray);

List Users

function listUsers(){
  $listUsersArray = array();
  return $this->sendRequest('user/list', $listUsersArray);

List Pending Users

function listPendingUsers(){
  $listPendingUsersArray = array();
  return $this->sendRequest('user/pending', $listPendingUsersArray);

Get User Info

function getUserInfo(){
  $getUserInfoArray = array();
  $getUserInfoArray['id'] = $_POST['userId'];
  return $this->sendRequest('user/get',$getUserInfoArray);

Get User Info By Email

function getUserInfoByEmail(){
  $getUserInfoByEmailArray = array();
  $getUserInfoByEmailArray['email'] = $_POST['userEmail'];
  $getUserInfoByEmailArray['login_type'] = $_POST['userLoginType'];
  return $this->sendRequest('user/getbyemail',$getUserInfoByEmailArray);

Update User Info

function updateUserInfo(){
  $updateUserInfoArray = array();
  $updateUserInfoArray['id'] = $_POST['userId'];
  return $this->sendRequest('user/update',$updateUserInfoArray);

Update User Password

function updateUserPassword(){
  $updateUserPasswordArray = array();
  $updateUserPasswordArray['id'] = $_POST['userId'];
  $updateUserPasswordArray['password'] = $_POST['userNewPassword'];
  return $this->sendRequest('user/updatepassword', $updateUserPasswordArray)

Set User Assistant

function setUserAssistant(){
  $setUserAssistantArray() = array();
  $setUserAssistantArray['id'] = $_POST['userId'];
  $setUserAssistantArray['host_email'] = $_POST['userEmail'];
  $setUserAssistantArray['assistant_email'] = $_POST['assistantEmail'];
  return $this->sendRequest('user/assistant/set', $setUserAssistantArray);

Delete User Assistant

function deleteUserAssistant(){
  $deleteUserAssistantArray = array();
  $deleteUserAssistantArray['id'] = $_POST['userId'];
  $deleteUserAssistantArray['host_email'] = $_POST['userEmail'];
  $deleteUserAssistantArray['assistant_email'] = $_POST['assistantEmail'];
  return $this->sendRequest('user/assistant/delete',$deleteUserAssistantArray);

Revoke SSO Token

function revokeSSOToken(){
  $revokeSSOTokenArray = array();
  $revokeSSOTokenArray['id'] = $_POST['userId'];
  $revokeSSOTokenArray['email'] = $_POST['userEmail'];
  return $this->sendRequest('user/revoketoken', $revokeSSOTokenArray);

Delete User Permanently

function deleteUserPermanently(){
  $deleteUserPermanentlyArray = array();
  $deleteUserPermanentlyArray['id'] = $_POST['userId'];
  $deleteUserPermanentlyArray['email'] = $_POST['userEmail'];
  return $this->sendRequest('user/permanentdelete', $deleteUserPermanentlyArray);

Meeting API Example Calls

For information on all possible parameters and expected response, please see the REST Meeting API documentation.

Create A Meeting

function createAMeeting(){
  $createAMeetingArray = array();
  $createAMeetingArray['host_id'] = $_POST['userId'];
  $createAMeetingArray['topic'] = $_POST['meetingTopic'];
  $createAMeetingArray['type'] = $_POST['meetingType'];
  return $this->sendRequest('meeting/create', $createAMeetingArray);

Delete A Meeting

function deleteAMeeting(){
  $deleteAMeetingArray = array();
  $deleteAMeetingArray['id'] = $_POST['meetingId'];
  $deleteAMeetingArray['host_id'] = $_POST['userId'];
  return $this->sendRequest('meeting/delete', $deleteAMeetingArray);

List Meetings

function listMeetings(){
  $listMeetingsArray = array();
  $listMeetingsArray['host_id'] = $_POST['userId'];
  return $this->sendRequest('meeting/list',$listMeetingsArray);

Get Meeting Info

function getMeetingInfo(){
  $getMeetingInfoArray = array();
  $getMeetingInfoArray['id'] = $_POST['meetingId'];
  $getMeetingInfoArray['host_id'] = $_POST['userId'];
  return $this->sendRequest('meeting/get', $getMeetingInfoArray);

Update Meeting Info

function updateMeetingInfo(){
  $updateMeetingInfoArray = array();
  $updateMeetingInfoArray['id'] = $_POST['meetingId'];
  $updateMeetingInfoArray['host_id'] = $_POST['userId'];
  return $this->sendRequest('meeting/update', $updateMeetingInfoArray);

End A Meeting

function endAMeeting(){
  $endAMeetingArray = array();
  $endAMeetingArray['id'] = $_POST['meetingId'];
  $endAMeetingArray['host_id'] = $_POST['userId'];
  return $this->sendRequest('meeting/end', $endAMeetingArray);

List Recording

function listRecording(){
  $listRecordingArray = array();
  $listRecordingArray['host_id'] = $_POST['userId'];
  return $this->sendRequest('recording/list', $listRecordingArray);

Report API Example Calls

For information on all possible parameters and expected response, please see the REST Report API documentation.

Get Daily Report

function getDailyReport(){
  $getDailyReportArray = array();
  $getDailyReportArray['year'] = $_POST['year'];
  $getDailyReportArray['month'] = $_POST['month'];
  return $this->sendRequest('report/getdailyreport', $getDailyReportArray);

Get Account Report

function getAccountReport(){
  $getAccountReportArray = array();
  $getAccountReportArray['from'] = $_POST['from'];
  $getAccountReportArray['to'] = $_POST['to'];
  return $this->sendRequest('report/getaccountreport', $getAccountReportArray);

Get User Report

function getUserReport(){
  $getUserReportArray = array();
  $getUserReportArray['user_id'] = $_POST['userId'];
  $getUserReportArray['from'] = $_POST['from'];
  $getUserReportArray['to'] = $_POST['to'];
  return $this->sendRequest('report/getuserreport', $getUserReportArray);

Webinar API Example Calls

For information on all possible parameters and expected response, please see the REST Webinar API documentation.

Create A Webinar

function createAWebinar(){
  $createAWebinarArray = array();
  $createAWebinarArray['host_id'] = $_POST['userId'];
  $createAWebinarArray['topic'] = $_POST['topic'];
  return $this->sendRequest('webinar/create',$createAWebinarArray);

Delete A Webinar

function deleteAWebinar(){
  $deleteAWebinarArray = array();
  $deleteAWebinarArray['id'] = $_POST['webinarId'];
  $deleteAWebinarArray['host_id'] = $_POST['userId'];
  return $this->sendRequest('webinar/delete',$deleteAWebinarArray);

List Webinars

function listWebinars(){
  $listWebinarsArray = array();
  $listWebinarsArray['host_id'] = $_POST['userId'];
  return $this->sendRequest('webinar/list',$listWebinarsArray);

Get Webinar Info

function getWebinarInfo(){
  $getWebinarInfoArray = array();
  $getWebinarInfoArray['id'] = $_POST['webinarId'];
  $getWebinarInfoArray['host_id'] = $_POST['userId'];
  return $this->sendRequest('webinar/get',$getWebinarInfoArray);

Update Webinar Info

function updateWebinarInfo(){
  $updateWebinarInfoArray = array();
  $updateWebinarInfoArray['id'] = $_POST['webinarId'];
  $updateWebinarInfoArray['host_id'] = $_POST['userId'];
  return $this->sendRequest('webinar/update',$updateWebinarInfoArray);

End A Webinar

function endAWebinar(){
  $endAWebinarArray = array();
  $endAWebinarArray['id'] = $_POST['webinarId'];
  $endAWebinarArray['host_id'] = $_POST['userId'];
  return $this->sendRequest('webinar/end',$endAWebinarArray);
Was this article helpful?
Have more questions? Submit a request
Powered by Zendesk