How to import your Zoom Webinars into WordPress as custom content

How to automate importing zoom webinars into Wordpress

Hello!

Now, more than ever, companies businesses and individuals are leveraging web based collaborative tools like Zoom. Whether it be for company meetings, training sessions or sales seminars, the idea is to use video conferencing technology to replace in-person interactions.

Zoom has emerged as a leading player, being positioned favourably at the right point in time to offer reliable video conferencing services for a variety of uses. One of the more common requests as web development agency, is to integrate the ability to “import” Zoom webinars for a business into their website. What once may have been an Eventbrite integration has now transitioned to a remote model of interaction.

At Shift8, we have created a WordPress plugin to pull Zoom webinar events into WordPress as custom content. This can then be manipulated by your theme or a custom post grid perhaps.

Why would you want to import Zoom Webinar’s into WordPress?

Picture it : you have an established business selling a digital product. You already have sales funnels, training and support established for a sizable base of customers or potential customers. You have an established training and seminar process tied directly to your marketing, sales and support departments. You simply can no longer facilitate in-house seminars, training and meetings.

The idea is to swap in-person with video conferencing such as what can be offered to a Zoom for business user. The marketing department can continue to coordinate and facilitate these customer interactions through Zoom.

Now that the transition to Zoom is complete, we want to integrate this shift on the website.

Set up your Zoom account for API authentication

First and foremost before you use our plugin or integrate with Zoom’s API on your own, you need to create a JWT app in Zoom’s app marketplace. JWT stands for JSON Web Tokens and is really the way our plugin will be authenticating with Zoom to interact with their API.

Once your JWT app is created in your Zoom account, you should be able to obtain the API Key and Secret. Keep that safe for later.

Install our Shift8 Zoom WordPress Plugin

Once the plugin is installed, head over to the settings page (Shift8 > Zoom Settings) and enter all the relevant information in the settings. Pretty self explanatory but I’ll walk through each of the settings below for clarity.

Shift8 Zoom WordPress Settings

 

The user email field is the email address that you used to sign up for an account with Zoom. The API Key and Secret are what was generated when you created your Zoom JWT app in the marketplace.

The next setting, “Select Zoom Webinar import frequency” is obvious. This is how often you want the plugin to schedule an interaction where we check Zoom for new webinars and import them into WordPress. For most people , daily would make the most sense but there is shorter intervals that you can choose from. This leverage’s WordPress’ cron system so it might be ideal if you look into switching to linux’s cron to initiate WordPress scheduled tasks to improve efficiency and overall site speed.

The last setting on this page is “Zoom filter title”. What this allows you to do is have some pattern matching in the webinar title where if it does indeed match, our system skips the import. This could be advantageous if you are creating some test webinars that you would not want to be part of the automated import process. The filter pattern match could be anything and is case insensitive.

Once everything is entered correctly (and you hit the save changes button), you can go ahead and test that everything works by clicking the “manual import” button. This initiates the connection to Zoom as if it were scheduled but obviously manually initiated by you.

How to connect to Zoom to pull webinars into WordPress

To connect to and interact with the Zoom api, we are using the wonderful WordPress function wp_remote_get. This allows us to make a GET request to list all webinars and subsequently pull all the data for each webinar in order to import into the system. You can read more about the specific webinar API queries that are possible with Zoom.

$headers = array(
    'Content-type: application/json',
    'Authorization' => 'Bearer ' . $zoom_jwt_token,
);
$response = wp_remote_get( S8ZOOM_API . '/v2/users/' . $zoom_user_email . '/webinars',
    array(
             'method' => 'GET',
             'headers' => $headers,
             'httpversion' => '1.1',
             'timeout' => '45',
             'blocking' => true,
         )
);

First and foremost we need to create an authorization header that contains the JSON web token. The token is generated by another function in our plugin based on the API key and secret using standard methods.

We then craft a GET request via wp_remote_get with the headers in order to query the available webinars. One thing to note that we had to discover after some testing during the plugin development was that yes you can get all webinar data from this one query but the one thing that Zoom doesnt provide is the FULL webinar details (or agenda description). This would be the body details that you would fill out to describe the event. What is returned in the above query is a truncated or shortened version of the agenda description for each webinar item.

Before we go into how we pull the full details for each webinar, lets move to the portion of our code that imports the webinars into WordPress.

How to import Zoom webinars into WordPress

Now that we’ve pulled the webinar data (minus the full agenda description) for all webinars, we want to start sorting the data and import it into WordPress. First and foremost we want to make sure that the webinar doesn’t already exist in the system!

 $args = array(  
                  'post_type' => 'shift8_zoom',
                  'post_status' => 'publish',
                  'posts_per_page' => -1, 
                  'meta_query'     => array(
                      array(
                          'key'       => '_post_shift8_zoom_id',
                          'value'     => sanitize_text_field($webinar['id']),
                          'compare'   => '='
                      )
                  ),
                  'order' => 'ASC', 
              );
              $query = new WP_Query ( $args );
              // If ID exists, move on
              if ($query->have_posts()) {
                  continue;

Whats happening in the above snippet? Well we are crafting a WP_Query interaction with WordPress in order to check the webinar unique ID numbers with what we have already imported into the system , to avoid importing duplicate webinars. The ID we are talking about is really the webinar meeting ID that you would actually share with attendees of your webinar. These ID numbers are supposed to be unique and are a good indicator to check against to make sure you dont import duplicates.

So we are querying WordPress for the custom post types that our plugin created in order to pass a meta_query argument to check against the ID field in our custom content and see if it matches the ID that we are considering importing for that particular webinar that we are iterating against. If it exists, we continue on the iteration (we are using a foreach loop to iterate across all webinars). In a future release this could definitely be made more efficient by querying Zoom directly against webinar IDs that dont equate to whats in our system already. For an organization with a lot of webinars, this might save time during the API query poll time.

 

$webinar_post = array(
    'post_title'    => wp_strip_all_tags( $webinar['topic'] ),
    'post_status'   => 'publish',
    'post_type'     => 'shift8_zoom',
    'post_author'   => 1,
);

// Insert the post into the database
$post_id = wp_insert_post( $webinar_post );
update_post_meta( $post_id, "_post_shift8_zoom_uuid", sanitize_text_field( $webinar['uuid']) );
update_post_meta( $post_id, "_post_shift8_zoom_id", sanitize_text_field( $webinar['id']) );
update_post_meta( $post_id, "_post_shift8_zoom_language", 'English' );
update_post_meta( $post_id, "_post_shift8_zoom_type", sanitize_text_field( $webinar['type']) );
update_post_meta( $post_id, "_post_shift8_zoom_start", wp_date(Carbon::create(sanitize_text_field( $webinar['start_time'] ))) );
update_post_meta( $post_id, "_post_shift8_zoom_duration", sanitize_text_field( $webinar['duration'] ) );
update_post_meta( $post_id, "_post_shift8_zoom_timezone", sanitize_text_field( $webinar['timezone'] ) );
update_post_meta( $post_id, "_post_shift8_zoom_joinurl", sanitize_url( $webinar['join_url'] ) );
update_post_meta( $post_id, "_post_shift8_zoom_agenda_html", $webinar_agenda );

Once all thats done and we determine that this is a new webinar and we want to import it, we create a new post array and create the new post within our custom content type that the plugin created. Then once the post is created we facilitate the use of update_post_meta in order to update the additional custom fields for our content type

How to get the full agenda description for each webinar in Zoom

In order to pull the full agenda details we need to make an additional API query for each webinar (after we determine it doesnt already exist in our system). This extra query will give us the full details for that webinar, namely the agenda description :

     // Set headers for WP Remote post
    $headers = array(
        'Content-type: application/json',
        'Authorization' => 'Bearer ' . $zoom_jwt_token,
    );

    // Use WP Remote Get to poll the zoom api 
    $response = wp_remote_get( S8ZOOM_API . '/v2/webinars/' . intval($webinar_id),
        array(
            'method' => 'GET',
            'headers' => $headers,
            'httpversion' => '1.1',
            'timeout' => '45',
            'blocking' => true,
        )
    );

You can see in the above snippet that we are simply querying a direct webinar meeting ID, which should return the full (non truncated) details. You can read more about this particular query here.

Hopefully this helps you understand how we were able to create a WordPress plugin to pull Zoom webinars into your WordPress site!

 

Download the plugin here and try it out