My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
WikiPage  
Wiki version 1.0
Featured, Phase-Implementation, Phase-Deploy
Updated Aug 1, 2011 by guido.ro...@gmail.com

Google it!

Introduction

Simple Class Youtube, is a simple PHP class for obtaining information from a video on YouTube, through simple methods that provide the class.

Details

With this class, you can obtain:

  • Title.
  • Valid (is a valid video?)
  • Published.
  • Updated.
  • Category.
  • Tags.
  • Content.
  • Description.
  • Link.
  • Images.
  • Author Name.
  • Author Url.
  • Author Uri.
  • Embed Code.

Examples

Instantiation

Do you have two alternatives to instance the Simple Class Youtube

With the complete youtube url: http://www.youtube.com/watch?v=5ocq6_3-nEw

$url = 'http://www.youtube.com/watch?v=5ocq6_3-nEw';
$youtube = new Youtube($url);

Or with specific ID video: 5ocq6_3-nEw

$id = '5ocq6_3-nEw';
$youtube = new Youtube($id);

Valid Video

If URL is incorrect or ID is invalid, this method valid(); return false.

var_dump($youtube->valid());
//true in this example.

Title

For get video title, only use getTitle(); methods.

echo $youtube->getTitle();
//The Story of Linux: Commemorating 20 Years of the Linux Operating System

Published

For get video published time, use getPublished();

echo $youtube->getPublished();
//2011-03-31T20:12:23.000Z

Updated

For get video updated time, use getUpdated();

echo $youtube->getUpdated();
//2011-08-01T05:17:51.000Z

Category

For get video example category, use getCategory();

echo $youtube->getCategory();
//Science & Technology

Tags

For get video example tags, use getTags();

echo var_dump($youtube->getTags());
//Return array with a tags

Content

For get video example content (HTML provides Youtube), use getContent();

echo $youtube->getContent();
//Return HTML with video content

Description

For get video example description, use getDescription();

echo $youtube->getDescription();
//Celebrate the 20th Anniversary of Linux with us. Watch the Story of Linux to remember - or learn for the first time - how Linux disrupted a market and has begun to change the world. Do you see yourself in its story?

Link

For get video example Url, use getUrl();

echo $youtube->getUrl();
//http://www.youtube.com/watch?v=5ocq6_3-nEw

Image

For get video example Image, use getUrl(TYPE);

TYPE = [ default | 0 | 1 | 2 | 3 ]

echo $youtube->getImageUrl('default');
//http://i.ytimg.com/vi/5ocq6_3-nEw/default.jpg

Author Data

Author Name

For get video example username, use getAuthorName();

echo $youtube->getAuthorName();
//TheLinuxFoundation

Author Url

For get video example user url, use getAuthorUrl();

echo $youtube->getAuthorUrl();
//http://www.youtube.com/user/TheLinuxFoundation

Author Uri

For get video example user url, use getAuthorUri();

echo $youtube->getAuthorUri();
//http://gdata.youtube.com/feeds/users/thelinuxfoundation

Video

For get video example code embeb, use getEmbeb(OPTIONS);

To view the parameters allowed, please see http://code.google.com/apis/youtube/player_parameters.html

$options = array('autoplay' => 1);
echo $youtube->getEmbeb($options);
//<iframe class="youtube-player" type="text/html" width="425" height="349" src="http://www.youtube.com/embed/5ocq6_3-nEw?autoplay=1"></iframe>

Other example...

$options = array('autoplay' => 1, 'width' => 853, 'height' => 510, 'hd' => 1);
echo $youtube->getEmbeb($options);
//<iframe class="youtube-player" type="text/html" width="853" height="510" src="http://www.youtube.com/embed/5ocq6_3-nEw?autoplay=1&hd=1"></iframe>

In Progress...

Comment by salesian...@gmail.com, Jul 19, 2011

Super Cool. Gracias


Sign in to add a comment
Powered by Google Project Hosting