Now Hiring: Are you a driven and motivated 1st Line IT Support Engineer?

Dec. 11, 2020

How to Download Zoom Cloud Recordings by PHP Program ?

The Zoom API is the primary means for developers to access a collection of resources from Zoom. Apps can read and write to the resources and mirror some of the most popular features available in  such as creating a new meeting, creating, adding and removing users, viewing reports and dashboards on various usage, and so on using the Zoom API. Depending on your app’s use case, you can choose from Zoom's various APIs and implement the features accordingly.

This is how Zoom's marketplace define the usage of API's provided by Zoom. And indeed using those API's really helpful to reduce back-office operations for most of the companies.

For Cihangir Yoga / Istanbul  , we integrate their portals with Zoom thru API's and automate meeting creation for scheduled sessions, implement Zoom Web Client in class detail and when the session start users can watch the session thru this web client under the brand of Cihangir Yoga.

Our next challenge was to download cloud recordings to more cost effective storage and display these videos also on Web pages of the company. 

So, how we can automize the process without the need for manual intervention ? 

We implemented a batch job by PHP which checks the class sessions already ended for ready recordings. If recordings are available, job get the Download_URL of the recording by using RecordingGET API of Zoom.


After that by using CURL GET request we can download the files to any location on our storage area. 

But there are some tricks here. You probably get many errors while try to download these media files. Don't worry, we will give you the answers... 

Now, here is the PHP code to send GET request :

$ch = curl_init();
header('Content-Disposition: attachment; filename="'.$recfile->getId().'.mp4"');

// set URL and other appropriate options
$fp = fopen('public/upload/zoomvideos/'.$recfile->getId().'.mp4', 'w+');
curl_setopt($ch, CURLOPT_URL, $recfile->getDownloadUrl().'?access_token='.$authorization);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/octet-stream',
'Content-Description: File Transfer',

First of all all the recordings by default can only be downloaded by host of meeting only. So if you don't enable "Viewers Can Download" property on Zoom portal you will get the following error each time you try:


So, programmatically you have to tell Zoom that you are either host or acting on behalf of host. So to do that you have to set "access_token" at each time when you send the request. 

curl_setopt($ch, CURLOPT_URL, $recfile->getDownloadUrl().'?access_token='.$authorization);

But be careful at that point. If you also set "Authorization" token at header part you will get the same error. You only need that access_token nothing more. These JWT token has to be created each time when the request send.  

If you send the request with the same token you use before you will get the following error, so be careful:


If you wonder how to generate JWT token, here is a function for that also:

use Firebase\JWT\JWT;
protected function generateJWT()
$token = [
'iss' => $this::ZOOM_API_KEY,
'exp' => time() + 60,

return JWT::encode($token, $this::ZOOM_API_SECRET);

By that method in a loop of batch job you can download as many as cloud recordings you need. 

I hope that helps you all guys. 

If you have any questions, write as comments...

Stay At Home, Stay Healthy !

Leave a Comment