# PHP & JWT - Basic instructions

**URL:** <https://devforum.zoom.us/t/php-jwt-basic-instructions/15879>\
**Category:** API and Webhooks\
**Created:** [May 3, 2020, 5:01pm UTC](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879 "2020-05-03T17:01:24Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![samly](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@samly](https://devforum.zoom.us/u/samly)\
**Post date:** [May 6, 2020, 1:01pm UTC](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879/4 "2020-05-06T13:01:21Z")

</div>

Every REST API that uses a JWT may have their own structure for the payload. What is given by the library is just an example of a common format. Zoom tells you what format it needs, so just use that format, regardless of if the issuer parameter being used for the API key vs a URL.

I’ve not tested this exact example myself, but it should go something like:

```php
/* Based on the firebase/php-jwt docs with Zoom's specifications */
use \Firebase\JWT\JWT;

$key = "my api secret here";
$payload = array(
    "iss" => "my api token here",
    "exp" => time()+36000, // expire in 10 hours
);

$jwt = JWT::encode($payload, $key, 'HS256'); // use the secret to sign the payload with a specific hashing algorithim

print_r($jwt); // This is your JWT token. Paste it into https://jwt.io for verification that it is valid. 

/* Now we can talk to Zoom directly using Zoom's PHP example */

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.zoom.us/v2/users?status=active&page_size=30&page_number=1", //This is the Zoom API endpoint you'd hit to get a list of active users. 
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "authorization: Bearer {$jwt}", // You provide your JWT token in the Authorization header. 
    "content-type: application/json"
  ),
));

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

curl_close($curl);

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

```

Alternatively, if you do not want to use the `firebase/php-jwt` library, you can generate the token yourself. There’s an example from another user here that works with minimal modification: [JWT token creation](https://devforum.zoom.us/t/jwt-token-creation/15783/2)

---

_[View the full topic](https://devforum.zoom.us/t/php-jwt-basic-instructions/15879)._
