api.video

Features

Documentation

Tutorials

Helpful PHP Scripts Pt. 3 - Export All Your Video Details to a .csv File

January 29, 2021 - Erikka Innes

In our 3rd installment of helpful PHP scripts (again from Hervé Pita) for bulk video uploads, we'll take a look at how to export all your video data to a .csv file. This script is part of a collection of scripts that help with bulk video uploads. All are available in our Helpful PHP Scripts repository on Github. In each part of this series, we'll walk through how to set up one of them. The scripts you'll find include:

We'll be talking about Export All Your Video Data to .csv today! You'll be able to see:

  • videoId - the unique identifier for referencing the video in API calls
  • title - the title of the video
  • publishedAt - when a video was published, in ISO-8601 format
  • iframe code - the code for embedding your video as an iframe
  • thumbnail - the thumbnail image for the video if one was set
  • mp4Support - the URL for the mp4 of the video if one is available
  • metadata - all key value pairs you set to describe the video (if you didn't set any you won't have them)

You can use the videoId to associate the video with a custom player you created.

Now that you know what kind of data you'll receive, let's get started!

Prerequisites

For this project you'll need:

  • PHP 5.4 or greater with the command-line interface (CLI) and JSON extension installed
  • The Composer dependency management tool (or another way to manage your dependency management). See the Composer website for installation options.
  • A GitHub account
  • An api.video account
  • Your API key for either production or sandbox

Installation

  1. Navigate to the Helpful PHP Scripts repository.
  2. Click Code and from the drop-down click Download ZIP. (You can also install from the CLI if you prefer.)
  3. Put the contents of your new .zip file in a folder you want to work from.
  4. Navigate to the folder containing the contents of your zip file in the terminal.
  5. In the terminal, type: composer require api-video/php-sdk

Try the Script

  1. In the terminal, type php create_csv.php
  2. You're asked what environment you want to use, prod or sandbox. For our walkthrough, choose prod. NOTE: You should choose the environment you have videos for. If you choose one of these environments and don't have videos stored there, you won't get any data to review.
  3. Provide your API key. You can get this by navigating to my.api.video and copying the appropriate key.
  4. Your .csv file will build and be output to project_details.csv.

Thanks for checking out our latest installment of Helpful PHP scripts!

Erikka Innes

Developer Evangelist

Get started now

Connect your users with videos