Posted by : Randy Cooper in (CDN)

Use the YouTube API with PHP

When it comes to online video sharing, the most popular site by far is YouTube, with billions of page views and hundreds of thousands of videos added daily. It’s not just home videos either: today, YouTube offers music videos, clips from TV shows, trailers of upcoming movies, animation clips, and much more. The service also allows users to tag videos with keywords, and view the most popular videos at any given time.

One of YouTube’s cooler features is its YouTube Data API, which allows developers to access and search YouTube video data through a REST-based API, and integrate this data into their own XML-aware application. This isn’t particularly difficult to do—you write application-level code to send REST requests, parse and decode responses, and integrate the resulting data into the application interface. If you use PHP, you can perform these tasks either through YouTube’s PHP Client Library, or manually parse the XML responses to your REST requests.

This article discusses the latter method, showing you how to access public content through the YouTube API and integrate this content into your PHP application using SimpleXML. It includes examples that retrieve video listings in specific categories; search for videos by keyword; retrieve video metadata, including thumbnails and statistics; and access user profile information.


Make a comment