Install Zend Framework to use Youtube Data API (Linux Debian Wheezy / Ubuntu)

Zend Framework 2 is an open source framework for developing web applications and services using PHP 5.3+. Companies such as Google and StrikeIron have partnered with Zend to provide interfaces to web services and other technologies they wish to make available to Zend Framework 2 developers. In the OSHL-UMH, Zend Framework is used to access some Google Services, such as Youtube or GMaps. Zend Framework works under BSD License.

 

Some steps are required to set up Zend Framework under Debian GNU/Linux:

1) As root, install Apache2, PHP5  (optionally, MySQL Server):

# apt-get install apache2 mysql-server php5 libapache2-mod-php5

2) Next, install Zend Framework:

# apt-get install zendframework

3) Install Apache Rewrite module:

# a2enmod rewrite

4) Restart Apache 2:

# /etc/init.d/apache2 restart

 

Now, your Zend Framework should work correctly. You can probe it with a simple script:

 

<?php

require_once ‘Zend/Loader.php’; // the Zend dir must be in your include_path
Zend_Loader::loadClass(‘Zend_Gdata_YouTube’);
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2.1);

$query = $yt->newVideoQuery();
$query->videoQuery=’titulo’; // where ‘titulo’ put some string about the videos’ title you would like to show
$query->setOrderBy(‘viewCount’);
$videoFeed= $yt->getVideoFeed($query);

echo $query->queryUrl . «\n»;

foreach ($videoFeed as $videoEntry) {
echo «———VIDEO———-\n»;
echo «Title: » . $videoEntry->getVideoTitle() . «\n»;
echo «\nDescription:\n»;
echo $videoEntry->getVideoDescription();
}

?>

 

4 Comments