# Help with api create meeting with php

**URL:** <https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189>\
**Category:** API and Webhooks\
**Created:** [July 25, 2019, 8:02pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189 "2019-07-25T20:02:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike1](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/mike1/32/1376_2.png) [@mike1](https://devforum.zoom.us/u/mike1)\
**Post date:** [July 25, 2019, 8:02pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/1 "2019-07-25T20:02:54Z")

</div>

Hi All,

I am having issues getting the create meeting to work with PHP using JWT. I have validated that my Bearer token is valid using [jwt.io](http://jwt.io) but anytime I make a call to create the meeting I get “invalid access token” Can someone take a look at my code below and let me know/point me in the right direction to get his working correctly? Thanks in advance!

```
use \Firebase\JWT\JWT;
class Zoom_Api {
		private $zoom_api_key = '###';
		private $zoom_api_secret = '#####';
		
		protected function sendRequest($data) {
            $request_url = 'https://api.zoom.us/v2/users/me/meetings';
            $headers = array(
				'authorization' => 'Bearer ' . $this->generateJWTKey(),
				'content-type' => 'application/json'
            );
           $postFields = json_encode($data);
		   $ch = curl_init();
			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
			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);
			$err = curl_error($ch);
			curl_close($ch);
			if(!$response){
				return $err;
			}
			return json_decode($response);
		}

		//function to generate JWT
        private function generateJWTKey() {
            $key = $this->zoom_api_key;
            $secret = $this->zoom_api_secret;
            $token = array(
                "iss" => $key,
                "exp" => time() + 3600 //60 seconds as suggested
            );
            return JWT::encode( $token, $secret );
        }
		
		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['meetingTopic'];
            $createAMeetingArray['agenda'] = ! empty( $data['agenda'] ) ? $data['agenda'] : "";
            $createAMeetingArray['type'] = ! empty( $data['type'] ) ? $data['type'] : 2; //Scheduled
            $createAMeetingArray['start_time'] = $start_time;
            $createAMeetingArray['timezone'] = $data['timezone'];
            $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 $z->message;
} catch (Exception $ex) {
echo $ex;
}
```

---

<div class="post-metadata">

**Author:** ![ruben](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@ruben](https://devforum.zoom.us/u/ruben)\
**Post date:** [July 25, 2019, 9:47pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/2 "2019-07-25T21:47:38Z")

</div>

Try with this:

$headers = array(  
“authorization: {$this-\>generateJWTKey()}”,  
‘content-type: application/json’  
);

The problem is that you’re using ‘=\>’ in the definition of your $headers array.

---

<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 25, 2019, 9:51pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/3 "2019-07-25T21:51:05Z")

</div>

Thanks Ruben!

@mike1 let us know if this works for you!

---

<div class="post-metadata">

**Author:** ![ruben](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@ruben](https://devforum.zoom.us/u/ruben)\
**Post date:** [July 25, 2019, 9:57pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/4 "2019-07-25T21:57:27Z")

</div>

It’s working for me!

---

<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 25, 2019, 10:07pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/5 "2019-07-25T22:07:16Z")

</div>

Great! Thanks for your help Ruben!

---

<div class="post-metadata">

**Author:** ![mike1](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/mike1/32/1376_2.png) [@mike1](https://devforum.zoom.us/u/mike1)\
**Post date:** [July 25, 2019, 10:15pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/6 "2019-07-25T22:15:10Z")

</div>

Yep its working. Thanks Ruben!

Funny how you miss something little when you have been starring at a code screen all day 🙂

---

<div class="post-metadata">

**Author:** ![mike1](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/mike1/32/1376_2.png) [@mike1](https://devforum.zoom.us/u/mike1)\
**Post date:** [July 25, 2019, 10:16pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/7 "2019-07-25T22:16:22Z")

</div>

One note though I had to keep the Bearer text like so  
$headers = array(  
‘authorization: Bearer ‘.$this-\>generateJWTKey().’’,  
‘content-type:application/json’  
);

---

<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 25, 2019, 10:26pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/8 "2019-07-25T22:26:05Z")

</div>

Haha happens to everyone! Glad it’s working now!

---

<div class="post-metadata">

**Author:** ![shady.work.it](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/shady.work.it/32/8502_2.png) [@shady.work.it](https://devforum.zoom.us/u/shady.work.it)\
**Post date:** [May 15, 2020, 1:29am UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/10 "2020-05-15T01:29:35Z")

</div>

I Cant Run The Code Plz Help Me

\<?php use \Firebase\JWT\JWT; class Zoom\_Api { private $zoom\_api\_key = 'V0vJUrlBS---HWT7jX2GXQ'; private $zoom\_api\_secret = 'Gm4o0mVsXk5qdlo71hFfJucqc2V1UeBhQqAa'; protected function sendRequest($data) { $request\_url = 'https://api.zoom.us/v2/users/me/meetings'; $headers = array( “authorization: {$this-\>generateJWTKey()}”, ‘content-type: application/json’ ); $postFields = json\_encode($data); $ch = curl\_init(); curl\_setopt($ch, CURLOPT\_HTTPHEADER, $headers); 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); $err = curl\_error($ch); curl\_close($ch); if(!$response){ return $err; } return json\_decode($response); } //function to generate JWT private function generateJWTKey() { $key = $this-\>zoom\_api\_key; $secret = $this-\>zoom\_api\_secret; $token = array( "iss" =\> $key, "exp" =\> time() + 3600 //60 seconds as suggested ); return JWT::encode( $token, $secret ); } 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['meetingTopic']; $createAMeetingArray['agenda'] = ! empty( $data['agenda'] ) ? $data['agenda'] : ""; $createAMeetingArray['type'] = ! empty( $data['type'] ) ? $data['type'] : 2; //Scheduled $createAMeetingArray['start\_time'] = $start\_time; $createAMeetingArray['timezone'] = $data['timezone']; $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 $z-\>message; } 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:** [May 19, 2020, 6:09pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/11 "2020-05-19T18:09:17Z")

</div>

Hey @shady.work.it,

Please provide a description of what you are trying to do. Your post is very unreadable.

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![daniel.cruz](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/daniel.cruz/32/8735_2.png) [@daniel.cruz](https://devforum.zoom.us/u/daniel.cruz)\
**Post date:** [May 28, 2020, 11:09pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/12 "2020-05-28T23:09:12Z")

</div>

**Help Invalid access token.**

class ZoomController  
{

```
private $zoom_api_key = 'key';

private $zoom_api_secret = 'secret';

public function zoom()
{

    #$zoom_meeting = new ZoomController();

    try{

    $z = $this->createAMeeting(

        array(

            'start_date'=>date("Y-m-d h:i:s", strtotime('tomorrow')),

            'topic'=>'Example Test Meeting'

        )

    );

    echo $z->message;

    } catch (Exception $ex) {

    echo $ex;

    }

}

protected function sendRequest($data)
{

    $request_url = 'https://api.zoom.us/v2/users/12345678901/meetings';

    $headers = array ("authorization: {$this->generateJWTKey()}", "content-type:application/json");

    
   $postFields = json_encode($data);

   $ch = curl_init();

    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    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);

    $err = curl_error($ch);

    curl_close($ch);

    if(!$response){

        return $err;

    }

    return json_decode($response);

}

//function to generate JWT

private function generateJWTKey() 

{

    $key = $this->zoom_api_key;

    $secret = $this->zoom_api_secret;

    $token = array(

        "iss" => $key,

        "exp" => time() + 3600 //60 seconds as suggested

    );

    

    return JWT::encode( $token, $secret );

}

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'] = $start_time;

    $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);

}

```

}

---

<div class="post-metadata">

**Author:** ![lakruroshan](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/lakruroshan/32/7187_2.png) [@lakruroshan](https://devforum.zoom.us/u/lakruroshan)\
**Post date:** [May 29, 2020, 12:04am UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/13 "2020-05-29T00:04:44Z")

</div>

[settings] =\> stdClass Object ( [host\_video] =\> 1 [participant\_video] =\> [cn\_meeting] =\> [in\_meeting] =\> [join\_before\_host] =\> 1 [mute\_upon\_entry] =\> 1 [watermark] =\> [use\_pmi] =\> [approval\_type] =\> 2 [audio] =\> voip [auto\_recording] =\> local [enforce\_login] =\> [enforce\_login\_domains] =\> [alternative\_hosts] =\> [close\_registration] =\> [registrants\_confirmation\_email] =\> 1 [waiting\_room] =\> 1 [registrants\_email\_notification] =\> 1 [meeting\_authentication] =\> )

i dont want this i just only need this  
stdClass Object ( [uuid] =\> yVVnTofJSn+qG4B0DWMUZw== [id] =\> \*\*\*\*\*\*\*\*\*\*\* [host\_id] =\> NOGCFsCyRwe\_cvyntO6s7g [topic] =\> යාපා බණ්ඩාර Sir Class [type] =\> 2 [status] =\> waiting [start\_time] =\> 2020-05-30T04:30:00Z [duration] =\> 60 [timezone] =\> Asia/Kolkata [created\_at] =\> 2020-05-29T00:02:29Z [start\_url] =\> [https://us04web.zoom.us/s/77386204622?zak=eyJ6bV9za20iOiJ6bV9vMm0iLCJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjbGllbnQiLCJ1aWQiOiJOT0dDRnNDeVJ3ZV9jdnludE82czdnIiwiaXNzIjoid2ViIiwic3R5IjoxLCJ3Y2QiOiJ1czA0IiwiY2x0IjowLCJzdGsiOiJWbGpfZ2ZJSkVOVWYwdmJGX1hlcGhWQzVpV21tcHEzTmVsY1YtdnZrLTVZLkVnSUFBQUZ5WGJ5Nnd3QUFIQ0FnZGpoNVJpdDRkVFpWWTNremFFODRMMHhKUVVoUGQzRkRaVE5XVUVsSGQzZ0FERE5EUWtGMWIybFpVek56UFFSMWN6QTAiLCJleHAiOjE1OTA3MTc3NDksImlhdCI6MTU5MDcxMDU0OSwiYWlkIjoiX28wVW1oVjlTN3l3bmZ0Rm52bEZEdyIsImNpZCI6IiJ9.V55D97nzAMnad7MH1gtjgZGuOu4\_mI75iA9w8OnNekc](https://us04web.zoom.us/s/77386204622?zak=eyJ6bV9za20iOiJ6bV9vMm0iLCJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJjbGllbnQiLCJ1aWQiOiJOT0dDRnNDeVJ3ZV9jdnludE82czdnIiwiaXNzIjoid2ViIiwic3R5IjoxLCJ3Y2QiOiJ1czA0IiwiY2x0IjowLCJzdGsiOiJWbGpfZ2ZJSkVOVWYwdmJGX1hlcGhWQzVpV21tcHEzTmVsY1YtdnZrLTVZLkVnSUFBQUZ5WGJ5Nnd3QUFIQ0FnZGpoNVJpdDRkVFpWWTNremFFODRMMHhKUVVoUGQzRkRaVE5XVUVsSGQzZ0FERE5EUWtGMWIybFpVek56UFFSMWN6QTAiLCJleHAiOjE1OTA3MTc3NDksImlhdCI6MTU5MDcxMDU0OSwiYWlkIjoiX28wVW1oVjlTN3l3bmZ0Rm52bEZEdyIsImNpZCI6IiJ9.V55D97nzAMnad7MH1gtjgZGuOu4_mI75iA9w8OnNekc) [join\_url] =\> [https://us04web.zoom.us/j/77386204622?pwd=YW50VFlSVWpYNllybFJxK3hNa3pMZz09](https://us04web.zoom.us/j/77386204622?pwd=YW50VFlSVWpYNllybFJxK3hNa3pMZz09) [password] =\> 1tHNZ2 [h323\_password] =\> 465928 [pstn\_password] =\> 465928 [encrypted\_password] =\> YW50VFlSVWpYNllybFJxK3hNa3pMZz09

how can i do that

\*This post has been edited to remove any meeting / webinar IDs

---

<div class="post-metadata">

**Author:** ![massengupta](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/massengupta/32/3954_2.png) [@massengupta](https://devforum.zoom.us/u/massengupta)\
**Post date:** [June 1, 2020, 7:14pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/14 "2020-06-01T19:14:32Z")

</div>

This worked for me  
$headers = array( “authorization: Bearer {$this-\> generateJWTKey()}”,  
“content-type: application/json” );

---

<div class="post-metadata">

**Author:** ![junaidali9559](https://avatars.discourse-cdn.com/v4/letter/j/9dc877/32.png) [@junaidali9559](https://devforum.zoom.us/u/junaidali9559)\
**Post date:** [June 2, 2020, 6:27am UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/15 "2020-06-02T06:27:14Z")

</div>

Hey Mike!!  
Can you help about api create meeting. I’m new to zoom and i want to create meeting using php and jwt can you provide me your sample app with php code.  
thanks regards

---

<div class="post-metadata">

**Author:** ![michael.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/michael.zoom/32/37213_2.png) [@michael.zoom](https://devforum.zoom.us/u/michael.zoom)\
**Post date:** [June 2, 2020, 4:07pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/16 "2020-06-02T16:07:01Z")

</div>

Hi @junaidali9559 from our Create a Meeting API docs:

> **[Create a Meeting - Meetings - Zoom API - API Reference](https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingcreate)**
>
> Create a meeting for a user. This API has a daily rate limit of 100 requests per day. Therefore, only 100 Create a Meeting API requests are permitted wi...

This uses the pecl/http2 library:

```php
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"topic":"string","type":"integer","start_time":"string [date-time]","duration":"integer","schedule_for":"string","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"}}');

$request->setRequestUrl('https://api.zoom.us/v2/users/xxxxxxxxxxxx/meetings');
$request->setRequestMethod('POST');
$request->setBody($body);

$request->setHeaders(array(
  'content-type' => 'application/json',
  'authorization' => 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOm51bGwsImlzcyI6InZlVmFjM1pUUV8tT3JTR1hRaDNvUEEiLCJleHAiOjE1ODczNDU4NTUsImlhdCI6MTU4NzM0MDQ1NX0.UP9SEMsrh10zBfwrIyAeo-pMyOlRYVqXMhW4TGZemM0'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();

```

---

<div class="post-metadata">

**Author:** ![yash.sakali](https://avatars.discourse-cdn.com/v4/letter/y/a698b9/32.png) [@yash.sakali](https://devforum.zoom.us/u/yash.sakali)\
**Post date:** [June 20, 2020, 5:34am UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/18 "2020-06-20T05:34:37Z")

</div>

Hi all,  
I am having issues getting the create meeting to work with PHP using JWT. i am getting blank page please help me to solve my issue.Thanks in advance.

\<?php require\_once 'jwt/BeforeValidException.php';  
require\_once 'jwt/ExpiredException.php';  
require\_once 'jwt/SignatureInvalidException.php';  
require\_once 'jwt/JWT.php';  
use \Firebase\JWT\JWT;  
class Zoom\_Api {  
 private $zoom\_api\_key = 'xxxxx';  
 private $zoom\_api\_secret = 'xxxxxx';  
 protected function sendRequest($data) {  
 $request\_url = 'https://api.zoom.us/v2/users/me/meetings';  
 $headers = array(  
"authorization: {$this-\>generateJWTKey()}",  
'content-type: application/json'  
);  
 $postFields = json\_encode($data);  
 $ch = curl\_init();  
 curl\_setopt($ch, CURLOPT\_HTTPHEADER, $headers);  
 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);  
 $err = curl\_error($ch);  
 curl\_close($ch);  
 if(!$response){  
 return $err;  
 }  
 return json\_decode($response);  
 }  
 //function to generate JWT  
 private function generateJWTKey() {  
 $key = $this-\>zoom\_api\_key;  
 $secret = $this-\>zoom\_api\_secret;  
 $token = array(  
 "iss" =\> $key,  
 "exp" =\> time() + 3600 //60 seconds as suggested  
 );  
 // $token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOm51bGwsImlzcyI6Ik5EdlI3TnN2U1ZLM2FqNEdGOWpKY1EiLCJleHAiOjE1OTI1NzA1OTksImlhdCI6MTU5MjU2NTIwMH0.P\_WVeUtIOuaHp9MslWWPhyfoDelSSceARVxHucYT-yM"; return JWT::encode( $token, $secret ); }  
 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['meetingTopic'];  
 $createAMeetingArray['agenda'] = ! empty( $data['agenda'] ) ? $data['agenda'] : "";  
 $createAMeetingArray['type'] = ! empty( $data['type'] ) ? $data['type'] : 2; //Scheduled  
 $createAMeetingArray['start\_time'] = $start\_time;  
 $createAMeetingArray['timezone'] = $data['timezone'];  
 $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')),  
 'meetingTopic'=\>'Example Test Meeting',  
 'timezone'=\>'Asia/Tashkent'  
 )  
);  
print\_r($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:** [June 23, 2020, 8:30pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/19 "2020-06-23T20:30:58Z")

</div>

Hey @yash.sakali,

Please share a screenshot of the blank page issue. Also make sure you are making a POST request to [create the meeting](https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingcreate).

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![yash.sakali](https://avatars.discourse-cdn.com/v4/letter/y/a698b9/32.png) [@yash.sakali](https://devforum.zoom.us/u/yash.sakali)\
**Post date:** [June 24, 2020, 3:55am UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/20 "2020-06-24T03:55:57Z")

</div>

Thank you for your valuable response.its working now…if any issue I will mail you…

---

<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:** [June 24, 2020, 10:52pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/21 "2020-06-24T22:52:38Z")

</div>

Happy to hear you got it working!

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![DeveloperBot](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/developerbot/32/12632_2.png) [@DeveloperBot](https://devforum.zoom.us/u/DeveloperBot)\
**Post date:** [August 21, 2020, 10:26pm UTC](https://devforum.zoom.us/t/help-with-api-create-meeting-with-php/5189/22 "2020-08-21T22:26:28Z")

</div>


