No Webhook for New Videos In Vimeo Solution

August 31, 2021 in General
Image

While working in my field, I run into problems that have no typical solution. In this article, I want to cover one of those problems and shed some high-level explanation on how the problem was solved.

Overview

I built a mobile application that screamed videos from a Vimeo account. The process was pretty straight forward but when it came time to create automated push notifications for new videos, I was lost. Come to find out, Vimeo does not have webhooks that can be used when new videos were added using Vimeo’s dashboard. Vimeo did not appear to have a solution for this and given that the last update on the matter was in 2014, I am not sure there is ever going to be an official way.

I could simply just suggest a manual push notification to the client but this is a cheap copout without actually investigating the inner workings. The solution was pretty easy after learning the Vimeo REST API. I find it important to understand the codebase and logic of code so I can then create custom solutions that others pass up.

The Issue

I wanted to send a push notification to a mobile application in relative real-time when a new video was published to the user’s Vimeo account. The issue is that Viemo does not have webhooks for this and they do not plan on supporting it. The end goal is that I want to automatically send push notifications to app users with data about a new video and even send them to the video when they click on the alert. To accomplish this, I need all kinds of information on demand that Viemo does not provide.

The Solution

Call the API using the “/me/videos” endpoint and capture all the videos that belong to the channel.

Create and store an array of each video’s URI and status. I created an array and encoded it into JSON and used a static file to store the index of videos and status.

Once there is a reference (the JSON file with the original video array), we can now monitor for videos that change from “unlisted” to “anybody”. We can find this by using array_diff in PHP. As long as one video’s privacy has been changed to “public” at a time, our script can catch the change.

Once a change is detected, we simply call Vimeos API for /me/videos/{video ID} to get the name and details about the video that was detected to have been changed. In this case, we store our video ID directly in the keys of the array so we can grab them easily when we check for a difference using array_diff in PHP.

Now that I have a way to see changes in the videos, I can handle new video push notifications by simply changing the status from private to public for a new video in Vimeo.

Limitations

I would be fooling myself if I thought there were no pitfalls to this logic. First, it can only detect one video change. In my case, this is all it has to do. The next thing is that Vimeo only provides 100 videos max through the API. Paging will be an issue and resource hog on the server. There is no other way.

Alternatives

I could have created an API client that uploaded the videos to Vimeo for the client. Once the video has been uploaded, I could send an Apple Push Notification. This is out of scope for the project and I will say a hurdle to build within anyone’s budget.