Summary
In the modern world it’s hard to create a good product without integrating it with third party services. One of the most popular services in the business world today is Zoom. I’d like to share some of the experience my team and I have had working with the Zoom API. Hope you enjoy the read and its helpful!
1. Zoom APP Creation
To work with the Zoom API, we can choose between OAuth and JWT (JSON web token) Zoom APP. Both provide a high level of security.
You can find more details on the Zoom docs pages: https://marketplace.zoom.us/docs/guides/build as well Build an App instructions.
In this example we will use JWT APP (JWT are an open, industry standard RFC 7519 method for representing claims securely between two parties).
Process of APP creation described on Zoom doc page: https://marketplace.zoom.us/docs/guides/build/jwt-app.
On this stage it allows us to get API Key and API Secret values.
<cfset jwtZoomAPISecret = “‘MY API Secret”>
<cfset jwtZoomAPIKey = “‘MY API Key”>
2. Generate an Access Token
We can download required library from JWT site: https://jwt.io/libraries or Github: https://github.com/jcberquist/jwt-cfml
function getZoomToken() {
var jwtObj = jwt(jwtZoomAPISecret);
var adjustedDate = DateAdd(“n”,”15?,Now());
var tokenExpiration = adjustedDate.getTime();
var payload = {
‘iss’ = jwtZoomAPIkey,
‘exp’ = tokenExpiration
};
var thetoken = jwtObj.encode(payload);
return thetoken;
}
3. Create a Meeting on Zoom using Zoom API
We need to use the previously generated token to Create a Meeting, as well as for other API integration.
We provided an example for Scheduled meeting, you can check Zoom documentation (https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingcreate) for other options.
<cfcomponent>
<cfset variables.APIServerURL = “https://api.zoom.us/v2/”>
<cffunction name=”init” output=”false” returntype=”Zoom”>
<cfargument name=”theToken” type=”string”>
<cfset variables.thetoken = arguments.thetoken>
<cfreturn this>
</cffunction>
<cffunction name=”createMeeting” access=”public” returntype=”any”>
<cfargument name=”topic” type=”string” required=”yes”>
<cfargument name=”start_time” type=”string” required=”yes”>
<cfargument name=”schedule_for” type=”string” required=”yes”>
<cfargument name=”password” type=”string” required=”yes”>
<cfargument name=”type” type=”numeric” default=”2?> //Scheduled Meeting
<cfargument name=”duration” type=”numeric” default=”30?>
<cfargument name=”timezone” type=”string” default=”America/New_York”>
<cfargument name=”agenda” type=”string” default=””>
<cfargument name=”registrants_email_notification” type=”boolean” default=”no”>
<cfsavecontent variable=”messagedata”>
<cfoutput>
{
“topic”: “#arguments.topic#”,
“type”: “#arguments.type#”,
“start_time”: “#arguments.start_time#”,
“duration”: “#arguments.duration#”,
“schedule_for”: “#arguments.schedule_for#”,
“timezone”: “#arguments.timezone#”,
“password”: “#arguments.password#”,
“agenda”: “#arguments.agenda#”,
“registrants_email_notification”: “#arguments.registrants_email_notification#”
}
}
</cfoutput>
</cfsavecontent>
<cfhttp url=”#APIServerURL#users/me/meetings” method=”post”>
<cfhttpparam type=”HEADER” name=”Content-Type” value=”application/json”>
<cfhttpparam type=”HEADER” name=”Authorization” value=”Bearer #variables.theToken#”>
<cfhttpparam type=”BODY” value=”#messagedata#”>
</cfhttp>
<cfset myResult = deserializeJSON(cfhttp.FileContent)>
<cfif cfhttp.statusCode contains “201”>
<cfreturn myResult>
<cfelse>
<cfreturn false>
</cfif>
</cffunction>
</cfcomponent>
4. Get Zoom Meetings
We can use another endpoint to get list of all meetings.
<cfcomponent>
<cfset variables.APIServerURL = “https://api.zoom.us/v2/”>
<cffunction name=”init” output=”false” returntype=”Zoom”>
<cfargument name=”theToken” type=”string”>
<cfset variables.thetoken = arguments.thetoken>
<cfreturn this>
</cffunction>
<cffunction name=”getMeetings” access=”public” returntype=”any”>
<cfhttp url=”#APIServerURL#users/me/meetings” method=”get”>
<cfhttpparam type=”HEADER” name=”Content-Type” value=”application/json”>
<cfhttpparam type=”HEADER” name=”Authorization” value=”Bearer #variables.theToken#”>
</cfhttp>
<cfset myResult = deserializeJSON(cfhttp.FileContent)>
<cfif cfhttp.statusCode contains “200”>
<cfreturn myResult>
<cfelse>
<cfreturn false>
</cfif>
</cffunction>
</cfcomponent>
5. Delete Zoom Meetings
We can play with the Zoom API endpoints like list, update, delete a meeting. All we need to do is follow their guidelines on using specific endpoints. For example, we can delete a meeting by sending a DELETE request to the API endpoint. To this endpoint, you need to pass your meeting id as shown below.
<cfcomponent>
<cfset variables.APIServerURL = “https://api.zoom.us/v2/”>
<cffunction name=”init” output=”false” returntype=”Zoom”>
<cfargument name=”theToken” type=”string”>
<cfset variables.thetoken = arguments.thetoken>
<cfreturn this>
</cffunction>
<cffunction name=”deleteMeeting” access=”public” returntype=”any”>
<cfargument name=”meetingId” type=”string” required=”yes”>
<cfhttp url=”#APIServerURL#meetings/#meetingId#” method=”delete”>
<cfhttpparam type=”HEADER” name=”Content-Type” value=”application/json”>
<cfhttpparam type=”HEADER” name=”Authorization” value=”Bearer #variables.theToken#”>
</cfhttp>
<cfif cfhttp.statusCode contains “204”>
<cfreturn true>
<cfelse>
<cfset myResult = deserializeJSON(cfhttp.FileContent)>
<cfreturn myResult >
</cfif>
</cffunction>
</cfcomponent>
Of course, this is just a small part of possible integrations. For example, if you have a multiple users in your account we can use Users endpoint https://marketplace.zoom.us/docs/api-reference/zoom-api/users/ to manage users. In the case we can reuse provided examples, we only need to replace ‘users/me/’ from provided examples with ‘users/[Actual User ID]/’