Recently, I was working on a project that required interacting with the Zoom API. In the client’s application, we implemented a lot of stuff using Zoom API like Accounts, Billing, Meetings, Groups, Reports, Rooms, etc. Though we did many things with the Zoom API, the main task was creating meetings. If you are the one who’s looking for the same then you are at the right place. In this tutorial, I will discuss how to create a meeting using Zoom API and PHP.
As we all know, Zoom is a platform used for teleconferencing, telecommuting, distance education, etc. It is popular for online conferences, meetings, and webinars.

Those looking to create meetings via the Zoom API need to implement the OAuth flow. OAuth provides a high level of security for interactions with third-party services. In this post, I’ll walk through the OAuth process for interacting with the Zoom API.
Create an OAuth App on Zoom
- xPlayUnmuteFullscreenhttps://imasdk.googleapis.com/js/core/bridge3.695.1_en.html#fid=goog_2006257136Advertisement: 0:08
-
Now Playing








x

Play Video
How to Add Interactive Magnifying Zoom for Images in WordPress Websites For Free_ ??
Share

How to Add Interactive Magnifying Zoom for Images in WordPress Websites For Free_ ??
Once you have your Zoom account, you have to create an OAuth app on Zoom using the below steps.
- Register your app on Zoom APP Marketplace.
- Upon registering an app, you will get your generated credentials. Here you need to pass Redirect URL for OAuth and Whitelist URL.
- In the next step, enter the basic information about your app.
- You can optionally enable some additional features such as Event Subscriptions and Chat Subscriptions for your app.
- Under the ‘Scopes’ tab, you need to add scopes regarding your app. For example, you can add a scope for Zoom meetings.
If you are on localhost then use the ngrok and generate the local URL. In my case, ngrok URLs for OAuth redirection and a Whitelist URL are shown below.


If you are facing any issues with creating an OAuth app please refer to Zoom’s official documentation on Create an OAuth App.
Basic Setup and Configuration
I didn’t find any PHP package for interacting with the Zoom API. So I decided to build the solution from scratch. After doing some back and forth I managed it through the Guzzle library and Zoom REST API. The Guzzle package is useful for handling HTTP requests and responses.
Install the Guzzle library using the command:
composer require guzzlehttp/guzzle
The Zoom REST API requires an access token. We are going to generate and store it in the database. The access token is valid for a short period. In our code, we will regenerate the access token in the background so that the user doesn’t need to do the authorization process again.
Let’s create a zoom_oauth table using the SQL below.
CREATE TABLE `zoom_oauth` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`provider` varchar(255) NOT NULL,
`provider_value` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
As we will require to fetch token values from the database, it needs to write a code for it. Create a file class-db.php and add the code below to it.
class-db.php
<?php
class DB {
private $dbHost = "DB_HOST";
private $dbUsername = "DB_USERNAME";
private $dbPassword = "DB_PASSWORD";
private $dbName = "DB_NAME";
public function __construct(){
if(!isset($this->db)){
// Connect to the database
$conn = new mysqli($this->dbHost, $this->dbUsername, $this->dbPassword, $this->dbName);
if($conn->connect_error){
die("Failed to connect with MySQL: " . $conn->connect_error);
}else{
$this->db = $conn;
}
}
}
public function is_table_empty() {
$result = $this->db->query("SELECT id FROM zoom_oauth WHERE provider = 'zoom'");
if($result->num_rows) {
return false;
}
return true;
}
public function get_access_token() {
$sql = $this->db->query("SELECT provider_value FROM zoom_oauth WHERE provider = 'zoom'");
$result = $sql->fetch_assoc();
return json_decode($result['provider_value']);
}
public function get_refresh_token() {
$result = $this->get_access_token();
return $result->refresh_token;
}
public function update_access_token($token) {
if($this->is_table_empty()) {
$this->db->query("INSERT INTO zoom_oauth(provider, provider_value) VALUES('zoom', '$token')");
} else {
$this->db->query("UPDATE zoom_oauth SET provider_value = '$token' WHERE provider = 'zoom'");
}
}
}
Make sure to replace the placeholders with your actual database credentials. Next, let’s generate an access token following the OAuth standard.
Generate an Access Token

The user can create an access token for their account using the App credentials and OAuth flow. Create a config.php file that will contain your app credentials and redirect URL. Also include the DB class and Guzzle package as follows.
config.php
<?php
require_once 'vendor/autoload.php';
require_once "class-db.php";
define('CLIENT_ID', 'YOUR_CLIENT_ID');
define('CLIENT_SECRET', 'YOUR_CLIENT_SECRET');
define('REDIRECT_URI', 'REDIRECT_URL_FOR_OAUTH');
Replace the placeholders with your app credentials. Set the same redirect URL you added in the Zoom OAuth app. In my case, the redirect URL is https://f2448150.ngrok.io/zoom/callback.php. It means in the callback.php file, we have to write code that calls the Zoom API, fetches an access token, and stores it in the database.
callback.php
<?php
require_once 'config.php';
try {
$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" => "authorization_code",
"code" => $_GET['code'],
"redirect_uri" => REDIRECT_URI
],
]);
$token = json_decode($response->getBody()->getContents(), true);
$db = new DB();
$db->update_access_token(json_encode($token));
echo "Access token inserted successfully.";
} catch(Exception $e) {
echo $e->getMessage();
}
Now, let’s generate an authorization URL where a user can click and complete the authorization. I am going to create this URL in the index.php file.

index.php
<?php
require_once 'config.php';
$url = "https://zoom.us/oauth/authorize?response_type=code&client_id=".CLIENT_ID."&redirect_uri=".REDIRECT_URI;
?>
<a href="<?php echo $url; ?>">Login with Zoom</a>
Run the above file on the browser, click on the ‘Login with Zoom’ link and complete the authorization. On successful authentication, you should see a success message and the access token would store in your zoom_oauth table. If it works, we can go ahead and create a meeting with the Zoom API.
Create a Meeting on Zoom using Zoom API
Zoom provides an endpoint for creating a meeting via its REST API. You may read about it in their documentation. It requires sending a POST request to the given endpoint along with the required parameters.
In addition to the parameters, you must send an access token in the Authorization header. As I said earlier, the access token has a short life and we are going to regenerate it in the background. This can be handled using the refresh token which we already got during authentication.
