a2zVideo API

Hits: 2241  

Welcome to the a2zVideoAPI wiki!

This API supports video links to get video information like Embed Code, Video Thumb, Video Title, Video Description etc.

How to use a2zVideoAPI:

1. Download “api.php” from http://github.com/svnlabs/a2zVideoAPI

2. API require PHP with CURL extension.. Setup / Upload “api.php” to your web server

3. Modify “api.php” for API Video server
curl_setopt($ch, CURLOPT_URL, ‘http://www.svnlabs.com/a2zvideoapi/server.php’);

4. There are currently 3 formats for API response

b. XML

$post = array( ‘url’ => “http://www.flickr.com/photos/schwartzray/2483697739/”, ‘format’ => “html” );

5. You have to use valid video page url like “http://www.youtube.com/watch?v=mXMf9GOzzOA” with format “html”, “xml” and “json”

6. Enjoy with svnlabs.com

Follow me….

Facebook: http://www.facebook.com/svnlabs
Twitter: http://www.twitter.com/svnlabs

Subscribe me….
Youtube: http://www.youtube.com/user/svnlabs
Feeds: http://blog.svnlabs.com/feed/

Download youtube videos using PEAR

Hits: 2120  

PEAR have rich library to access web based resources easily…


$sv = new SVTube();
$sv->download(“D7cm-yu-CP0”, “svnlabs.flv”)


Class: SVTube.php


require_once ‘HTTP/Client.php’;
require_once ‘HTTP/Request.php’;

class SVTube {

var $req;
var $debug = false;
var $auth = false;

function download ($video_id, $video_filename) {
$url = “http://www.youtube.com/watch?v=”.$video_id;
$this->req =& new HTTP_Request($url);
$response = $this->req->sendRequest();

if (PEAR::isError($response)) {
echo $response->getMessage().”\n”;
} else {
$page = $this->req->getResponseBody();

preg_match(‘/\&t=([^”]*)”/si’, $page, $match);

$html=html_entity_decode(urldecode(str_replace(‘\x’, ‘%’, $match[1])),ENT_QUOTES, “UTF-8”);

$echo = explode(“&”, $html);

$url = “http://www.youtube.com/get_video?el=detailpage&t=”.$echo[0].”&fmt=5&asv=3&video_id=”.$video_id;

if ($this->debug)
return $url.”\n”;

$req =& new HTTP_Request($url,array (“allowRedirects”=>true, “maxRedirects”=> 99));
$req->addHeader(“User-Agent”,”Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)”);
$response = $req->sendRequest();


if (PEAR::isError($response)) {
//echo $response->getMessage().”\n”;
return “Error: Failed to open video file on YouTube\n”;
} else {
if ($o = fopen ($video_filename, “w”)) {
fclose ($o);
return “Download complete! File: “.$video_filename.”\n”;
} else {
return “Error: Failed to open video-file\n”;