PHP Classes

PHP YouTube Movie Trailers 2018, 2017, 2016 or Any Year: Fetch and show YouTube movie trailers

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 324 All time: 7,202 This week: 524Up
Version License PHP version Categories
youtube-trailers 1.0.1GNU General Publi...7Web services, Video, PHP 7
Description 

Author

This package can fetch and show YouTube movie trailers without an API key.

It can send an HTTP requests to the YouTube site to retrieve and parse the YouTube search result pages for a trailer of a given movie.

Since it can search by year you may retrieve the list of trailers of 2018, 2017, 2016 or any other year you prefer.

The class extracts the identifier of the first result video and generates HTML to embed that video in a Web page.

Picture of Nitesh Apte
  Performance   Level  
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

 

Example

<?php
use YouTubeTrailer\Bean\Movie;
use
YouTubeTrailer\Core\YouTubeTrailer;
use
YouTubeTrailer\Bean\Trailer;

include_once
'autoload.php';

$movieBean = new Movie();
$movieBean->setMovieName($_GET['movie']);
$movieBean->setYearOfRelease($_GET['year']);
$movieBean->setLanguage($_GET['language']);

$trailerObj = new YouTubeTrailer();
$trailerBean = $trailerObj->getTrailerByNameAndYear($movieBean);

$id = $trailerBean->getId();
$type = $trailerBean->getContentType();
$width = $trailerBean->getWidth();
$height = $trailerBean->getHeight();
$video = $trailerBean->getMatch();
$param = $trailerBean->getParameterString();
$frame = $trailerBean->getFrameBody();
$fullscreen = $trailerBean->getAllowFullScreen();

$trailer = "<iframe id='$id' type='$type' width='$width' height='$height' src='https://www.youtube.com/embed/$video?$param' frameborder='$frame' allowfullscreen='$fullscreen'></iframe>";

echo
$trailer;


Details

YouTube Trailer 2.0

Fetch trailer from YouTube without API Key


  Files folder image Files (28)  
File Role Description
Files folder imagejscript (1 file, 1 directory)
Files folder imagelib (1 directory)
Accessible without login Plain text file autoload.php Aux. Autoload classes
Accessible without login Plain text file index.php Aux. Start app
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Readme
Accessible without login Plain text file trailer.php Example Usage

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:324
This week:0
All time:7,202
This week:524Up