Skip to content

Instantly share code, notes, and snippets.

@joshuawoodward
Created August 2, 2017 19:04
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save joshuawoodward/7574df3df9a089e2663582a2cf9f188b to your computer and use it in GitHub Desktop.
Save joshuawoodward/7574df3df9a089e2663582a2cf9f188b to your computer and use it in GitHub Desktop.
How to generate a signature for zoom in PHP
/**
* Generate signature for ZoomMtg JSSDK.
*
* @param string $api_key You REST API Key
* @param string $api_secret You REST API Secret
* @param int $meeting_number The meeting number you are creating the signature for
* @param int $role Role that this signature is for; 0 for participant, 1 for host
*
* @return string Returns the signature string
*
*/
function generate_signature ( $api_key, $api_sercet, $meeting_number, $role){
$time = time() * 1000; //time in milliseconds (or close enough)
$data = base64_encode($api_key . $meeting_number . $time . $role);
$hash = hash_hmac('sha256', $data, $api_sercet, true);
$_sig = $api_key . "." . $meeting_number . "." . $time . "." . $role . "." . base64_encode($hash);
//return signature, url safe base64 encoded
return rtrim(strtr(base64_encode($_sig), '+/', '-_'), '=');
}
@1mursaleen
Copy link

Thanks a lot!

@apoorvgohire28
Copy link

but it is generating wrong signature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment