PHP Classes

PHP YouTube API: Get video information using the YouTube API

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 111 All time: 9,625 This week: 524Up
Version License PHP version Categories
youtube-api 1.0.0Free for non-comm...5PHP 5, Web services, Video
Description 

Author

This package can be used to get video information using the YouTube API.

It can send HTTP requests to the YouTube API Web servers to perform several types of operations to access video information. Currently it can:

- Get information on a specific video
- Get information on a specific channel
- Get information on the top of the chart videos
- Get information on videos related to a specific video
- Search for videos with a given keyword

Picture of Rayhan Sardar
Name: Rayhan Sardar <contact>
Classes: 2 packages by
Country: United Kingdom
Age: ???
All time rank: 3284145 in United Kingdom
Week rank: 195 Up8 in United Kingdom Up

Documentation

YouTube API v3 PHP Wrapper & YouTube Downloader

A basic PHP wrapper for the Youtube Data API v3 ( Non-OAuth ). Designed to let devs easily fetch public data (Video & Channel) from Youtube. No 3rd party dependancy. The reason of returning the ARRAY response directly is to keep it simple.

Some parameters are missing in this library, because I don't need them at this point, if you desire a particular feature please file an issue here :smile:

Requirements

  • PHP >=5.3
  • CURL extension in PHP

Install

Run the following command in your command line shell in your php project

composer require madcodez/youtube

Usage

Example usage of getting "Top of the chart" videos :

<?php

require 'vendor/autoload.php';

$youtube = new Madcodez\YouTube\YouTube('Your API key here');

$chart = $youtube->chart('10', $pageToken);

print_r($chart);

Example usage of getting Category wise "Top of the chart" videos :

<?php

require 'vendor/autoload.php';

$youtube = new Madcodez\YouTube\YouTube('Your API key here');

$catVid = $youtube->videoByCat('2', '10', $pageToken);

print_r($catVid);

Example usage of Searching :

<?php
require 'vendor/autoload.php';

$youtube = new Madcodez\YouTube\YouTube('Your API key here');

$seach = $youtube->search('Web Development', '10', $pageToken);

print_r($search);

Example usage of video info :

<?php

require 'vendor/autoload.php';

$youtube = new Madcodez\YouTube\YouTube('Your API key here');

$video = $youtube->video('rie-hPVJ7Sw');

print_r($video);

Example usage of getting channel wise video :

<?php

require 'vendor/autoload.php';

$youtube = new Madcodez\YouTube\YouTube('Your API key here');

$channel = $youtube->channel('UC0gTtCL29NCuex5OApWXpPQ', '10', $pageToken);

print_r($channel);

Example usage of getting related videos :

<?php

require 'vendor/autoload.php';

$youtube = new Madcodez\YouTube\YouTube('Your API key here');

$related = $youtube->related('nLzV5l0Enww', '10', $pageToken);

print_r($related);

YouTube API Video Category ID :

2 - Autos & Vehicles

1 - Film & Animation

10 - Music

15 - Pets & Animals

17 - Sports

18 - Short Movies

19 - Travel & Events

20 - Gaming

21 - Videoblogging

22 - People & Blogs

23 - Comedy

24 - Entertainment

25 - News & Politics

26 - Howto & Style

27 - Education

28 - Science & Technology

29 - Nonprofits & Activism

30 - Movies

31 - Anime/Animation

32 - Action/Adventure

33 - Classics

34 - Comedy

35 - Documentary

36 - Drama

37 - Family

38 - Foreign

39 - Horror

40 - Sci-Fi/Fantasy

41 - Thriller

42 - Shorts

43 - Shows

44 - Trailers

Format of returned data

The returnd data is a PHP Array

Youtube Data API v3

Contact

For bugs, complain and suggestions please file an Issue here or send email to madcode.git@gmail.com :smile:

License

This library is licensed under the MIT License.


  Files folder image Files (5)  
File Role Description
Files folder imagesrc (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files (5)  /  src  
File Role Description
  Plain text file Http.php Class Class source
  Plain text file YouTube.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:111
This week:0
All time:9,625
This week:524Up