# Working with Zoom API with PHP

**URL:** <https://devforum.zoom.us/t/working-with-zoom-api-with-php/14794>\
**Category:** API and Webhooks\
**Created:** [April 24, 2020, 3:44pm UTC](https://devforum.zoom.us/t/working-with-zoom-api-with-php/14794 "2020-04-24T15:44:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![maksim](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/maksim/32/2370_2.png) [@maksim](https://devforum.zoom.us/u/maksim)\
**Post date:** [April 24, 2020, 3:44pm UTC](https://devforum.zoom.us/t/working-with-zoom-api-with-php/14794/1 "2020-04-24T15:44:21Z")

</div>

Hello!

I need to Zoom meetings to my website. So I need to generate meeting and links to join it. I have some questions about it. Is it possible to do this on free account? What API i must use? (I prefer users join meeting without login if its possible).

In my development I am tried to make different requests, but I am always getting in response:  
“Invalid access token.”

I tried different ways, and with [herokuapp.com](http://herokuapp.com), i have a lot of progress, but “continue” button not working for me, when I logged in.

I prefer the simplest solution, te create meeting and make join link, please help me with that, maybe some examples on PHP.

herokuapp CODE:  
$url = ‘[https://xxxxxx.herokuapp.com](https://xxxxxx.herokuapp.com)’;  
$data = array(‘meetingNumber’ =\> ‘’, ‘role’ =\> ‘0’);

```
// use key 'http' even if you send the request to https://...
$options = array(
    'http' => array(
        'header' => "Content-type: application/x-www-form-urlencoded\r\n",
        'method' => 'POST',
        'content' => http_build_query($data)
    )
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) { /* Handle error */ }

//var_dump($result);
$resAr = json_decode($result, true);
$signature = $resAr['signature'];
echo '
<div class="iframe-container" style="overflow: hidden; padding-top: 56.25%; position: relative;">
	<iframe allow="microphone; camera" style="border: 0; height: 100%; left: 0; position: absolute; top: 0; width: 100%;" src="https://success.zoom.us/wc/join/7945472637" frameborder="0"></iframe>
</div>
';

```

Or I try to make simple post request and I am getting wrong auth token:  
$curl = curl\_init();

```
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.zoom.us/v2/users//meetings",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\"topic\":\"string\",\"type\":\"integer\",\"start_time\":\"string [date-time]\",\"duration\":\"integer\",\"timezone\":\"string\",\"password\":\"string\",\"agenda\":\"string\",\"recurrence\":{\"type\":\"integer\",\"repeat_interval\":\"integer\",\"weekly_days\":\"string\",\"monthly_day\":\"integer\",\"monthly_week\":\"integer\",\"monthly_week_day\":\"integer\",\"end_times\":\"integer\",\"end_date_time\":\"string [date-time]\"},\"settings\":{\"host_video\":\"boolean\",\"participant_video\":\"boolean\",\"cn_meeting\":\"boolean\",\"in_meeting\":\"boolean\",\"join_before_host\":\"boolean\",\"mute_upon_entry\":\"boolean\",\"watermark\":\"boolean\",\"use_pmi\":\"boolean\",\"approval_type\":\"integer\",\"registration_type\":\"integer\",\"audio\":\"string\",\"auto_recording\":\"string\",\"enforce_login\":\"boolean\",\"enforce_login_domains\":\"string\",\"alternative_hosts\":\"string\",\"global_dial_in_countries\":[\"string\"],\"registrants_email_notification\":\"boolean\"}}",
  CURLOPT_HTTPHEADER => array(
    "authorization: Bearer g9o8vEE4wX_AoePQ40lQ5aEkQU-L4BB6A",
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
```

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [April 27, 2020, 11:24pm UTC](https://devforum.zoom.us/t/working-with-zoom-api-with-php/14794/2 "2020-04-27T23:24:48Z")

</div>

Hey @maksim,

Looks like you are just passing in your JWT API Key and not your [JWT Token](https://marketplace.zoom.us/docs/guides/auth/jwt).

```auto
"authorization: Bearer {JWT TOKEN HERE}"

```

Follow the guides here to embed the created meeting into your site:

> **[Web - Client SDKs - Zoom Software Development Kit (Zoom SDK)](https://marketplace.zoom.us/docs/sdk/native-sdks/web)**
>
> Zoom Web SDK
> 
> The Web SDK enables the development of video applications powered by Zoom's core framework inside an HTML5 web client through a highly opt...

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![nawoapp1](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/nawoapp1/32/11971_2.png) [@nawoapp1](https://devforum.zoom.us/u/nawoapp1)\
**Post date:** [July 15, 2020, 11:14pm UTC](https://devforum.zoom.us/t/working-with-zoom-api-with-php/14794/3 "2020-07-15T23:14:36Z")

</div>

You can create Zoom Meeting Using JWT API using the Following Php Code

```
    <?php

require_once 'config.php';

class Zoom_Api
{

    protected function sendRequest($data)
    {
        $request_url = "https://api.zoom.us/v2/users//meetings";

        $postFields = '{
        "topic": "New Meeting",
        "type": 2,
        "start_time": "2020-08-09T12:00:00Z",
        "duration": 45,
        "timezone": "America/Anchorage",
        "password": "1234",
        "agenda": "Zoom WordPress",
        "tracking_fields": [
          {
            "field": "string",
            "value": "string"
          }
        ],
        "settings": {
          "host_video": true,
          "participant_video": true,
          "cn_meeting": false,
          "in_meeting": false,
          "join_before_host": false,
          "mute_upon_entry": true,
          "watermark": false,
          "use_pmi": false,
          "approval_type": 0,
          "registration_type": 1,
          "audio":"voip", 
          "enforce_login": false,
          "enforce_login_domains": "",
          "alternative_hosts": "",
          "registrants_email_notification": false
        }
      }';

        $ch = curl_init();

        curl_setopt_array($ch, array(
            CURLOPT_URL => $request_url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => "",
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => "POST",
            CURLOPT_POSTFIELDS => $postFields,
            CURLOPT_HTTPHEADER => array(
                "authorization: Bearer",
                "content-type: application/json",
                "Accept: application/json",
            ),
        ));

        $response = curl_exec($ch);
        $err = curl_error($ch);
        curl_close($ch);
        if (!$response) {
            return $err;
        }
        return json_decode($response);
    }

    public function createAMeeting($data = array())
    {
        $post_time = $data['start_date'];
        $start_time = gmdate("Y-m-d\TH:i:s", strtotime($post_time));
        $createAMeetingArray = array();
        if (!empty($data['alternative_host_ids'])) {
            if (count($data['alternative_host_ids']) > 1) {
                $alternative_host_ids = implode(",", $data['alternative_host_ids']);
            } else {
                $alternative_host_ids = $data['alternative_host_ids'][0];
            }
        }
        $createAMeetingArray['topic'] = $data['topic'];
        $createAMeetingArray['agenda'] = !empty($data['agenda']) ? $data['agenda'] : "";
        $createAMeetingArray['type'] = !empty($data['type']) ? $data['type'] : 2; //Scheduled
        $createAMeetingArray['start_time'] = $start_time;
        $createAMeetingArray['timezone'] = 'PST';
        $createAMeetingArray['password'] = !empty($data['password']) ? $data['password'] : "";
        $createAMeetingArray['duration'] = !empty($data['duration']) ? $data['duration'] : 60;
        $createAMeetingArray['settings'] = array(
            'join_before_host' => !empty($data['join_before_host']) ? true : false,
            'host_video' => !empty($data['option_host_video']) ? true : false,
            'participant_video' => !empty($data['option_participants_video']) ? true : false,
            'mute_upon_entry' => !empty($data['option_mute_participants']) ? true : false,
            'enforce_login' => !empty($data['option_enforce_login']) ? true : false,
            'auto_recording' => !empty($data['option_auto_recording']) ? $data['option_auto_recording'] : "none",
            'alternative_hosts' => isset($alternative_host_ids) ? $alternative_host_ids : ""
        );
        return $this->sendRequest($createAMeetingArray);
    }
}

$zoom_meeting = new Zoom_Api();
try {

    $z = $zoom_meeting->createAMeeting(
        array(
            'start_date' => date("Y-m-d h:i:s", strtotime('tomorrow')),
            'topic' => 'Example Test Meeting'
        )
    );
    echo json_encode($z);
} catch (Exception $ex) {
    echo $ex;
}
```

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [July 17, 2020, 7:59pm UTC](https://devforum.zoom.us/t/working-with-zoom-api-with-php/14794/4 "2020-07-17T19:59:56Z")

</div>

Hey @nawoapp1,

Thanks for contributing to the Zoom Developer Community! 🙂

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![webrave](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/webrave/32/12967_2.png) [@webrave](https://devforum.zoom.us/u/webrave)\
**Post date:** [July 31, 2020, 5:30am UTC](https://devforum.zoom.us/t/working-with-zoom-api-with-php/14794/5 "2020-07-31T05:30:20Z")

</div>

Hi there. Where can one get a clear, simple example of joining Zoom meeting from a PHP app.

We have users in our database already. We want them to click one link and join a meeting. This should work for web and mobile so I doubt web sdk would the best fit.

We have setup outh0 but there is no clear guide that shows the custom app - auth0 - Zoom flow.

Most guides assume the developer should know certain concepts already.

Kindly assist

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [August 3, 2020, 8:38pm UTC](https://devforum.zoom.us/t/working-with-zoom-api-with-php/14794/6 "2020-08-03T20:38:47Z")

</div>

Hey @webrave,

Users simply have to click on the join\_url to join the meeting. What specifically are you needing help with?

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![webrave](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/webrave/32/12967_2.png) [@webrave](https://devforum.zoom.us/u/webrave)\
**Post date:** [August 3, 2020, 8:54pm UTC](https://devforum.zoom.us/t/working-with-zoom-api-with-php/14794/7 "2020-08-03T20:54:13Z")

</div>

Hi Tommy. I finally figured that out thanks. Nonetheless I would still like to get a guide on implementing the SSO. The Outh0-Zoom flow seems straight forward. I struggle with the app side of things. Basically developing from PHP.

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [August 4, 2020, 8:23pm UTC](https://devforum.zoom.us/t/working-with-zoom-api-with-php/14794/8 "2020-08-04T20:23:14Z")

</div>

Happy to hear you figured it out! 🙂

Thanks for your feedback!

-Tommy

---

<div class="post-metadata">

**Author:** ![pratham](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/pratham/32/34629_2.png) [@pratham](https://devforum.zoom.us/u/pratham)\
**Post date:** [January 31, 2022, 11:37am UTC](https://devforum.zoom.us/t/working-with-zoom-api-with-php/14794/9 "2022-01-31T11:37:13Z")

</div>

Having Problem when using same API with php CURL  
but it works with post man  
[http://api.zoom.us/v2/users?page\_size=300&status=active](http://api.zoom.us/v2/users?page_size=300&status=active)  
User-Agent: Zoom-Jwt-Request  
Authorization:Bearer [Redacted]  
Content-Type:application/json

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [February 4, 2022, 2:18am UTC](https://devforum.zoom.us/t/working-with-zoom-api-with-php/14794/10 "2022-02-04T02:18:55Z")

</div>

Hi, @pratham,

Welcome to the Developer Forum – happy to help. Can you share more details about the behavior you are seeing with the PHP CURL API request? If possible, please share a screenshot or video (with your personal identifiable information omitted) of the behavior you are seeing. This information will help diagnose what may be happening.

I’d also suggested searching for the forum for [Curl PHP](https://devforum.zoom.us/search?q=curl%20php) solutions, as the answer you may be available already. For reference, here is a developer forum you may find helpful :

> [@Join Meeting API](https://devforum.zoom.us/t/join-meeting-api/47243/2):
>
> Hi @mkhurramilyas, This should definitely be possible. You can send requests to our Create Meeting and GET Meeting APIs from a PHP framework. These endpoints will return a start\_url and join\_url for the host and participants to start/join Zoom Meetings: Here is an example of a request to create a meeting in PHP: \<?php $curl = curl\_init(); curl\_setopt\_array($curl, array( CURLOPT\_URL =\> "https://api.zoom.us/v2/users/%7BuserId%7D/meetings", CURLOPT\_RETURNTRANSFER =\> true, CURLOPT\_ENCOD…

Thanks,  
Donte
