<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Atom publishing protocol &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/atom-publishing-protocol/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>Iterate over YouTube Channel with Zend_Gdata_YouTube</title>
		<link>/2010/04/22/iterate-over-youtube-channel-with-zend_gdata_youtube/</link>
		<comments>/2010/04/22/iterate-over-youtube-channel-with-zend_gdata_youtube/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 14:07:56 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Atom]]></category>
		<category><![CDATA[Atom publishing protocol]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[GData]]></category>
		<category><![CDATA[Gdata services]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Google Inc.]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[player]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web application frameworks]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[World Wide Web]]></category>
		<category><![CDATA[YouTube Inc]]></category>
		<category><![CDATA[zend]]></category>

		<guid isPermaLink="false">/?p=1465</guid>
		<description><![CDATA[Read YouTube&#8217;s Feed in Zend App The task is to read the entire Gdata from a YouTube&#8217;s channel. It may sound easy, but as you may know Gdata is based on the Atom publishing protocol, and it naturally gives you only the latest few items. Of course Zend Framework has a large set of classes &#8230; <a href="/2010/04/22/iterate-over-youtube-channel-with-zend_gdata_youtube/" class="more-link">Continue reading <span class="screen-reader-text">Iterate over YouTube Channel with Zend_Gdata_YouTube</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/03/16/retrieving-youtube-channels-videos-with-zend_gdata_youtube/" rel="bookmark" title="Retrieving YouTube Channel&#8217;s Videos with Zend_Gdata_YouTube">Retrieving YouTube Channel&#8217;s Videos with Zend_Gdata_YouTube </a></li>
<li><a href="/2010/05/21/check-youtube-video-existence-with-zend_gdata_youtube/" rel="bookmark" title="Check YouTube Video Existence with Zend_Gdata_YouTube">Check YouTube Video Existence with Zend_Gdata_YouTube </a></li>
<li><a href="/2010/03/15/force-zend-casting-and-help-the-ide-autocompletion/" rel="bookmark" title="Force Zend Casting and Help the IDE Autocompletion">Force Zend Casting and Help the IDE Autocompletion </a></li>
<li><a href="/2010/04/26/mysql-expressions-in-zend-framework/" rel="bookmark" title="MySQL Expressions in Zend Framework">MySQL Expressions in Zend Framework </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Read YouTube&#8217;s Feed in Zend App</h2>
<p>The task is to read the entire <a title="Gdata" href="http://code.google.com/apis/gdata/" target="_blank">Gdata</a> from a YouTube&#8217;s channel. It may sound easy, but as you may know Gdata is based on the Atom publishing protocol, and it naturally gives you only the latest few items.</p>
<p>Of course <a title="Zend Framework" href="http://framework.zend.com/" target="_blank">Zend Framework</a> has a large set of classes dealing with Google&#8217;s Gdata services, one of them is the <a href="http://framework.zend.com/manual/en/zend.gdata.youtube.html" target="_blank">Zend_Gdata_YouTube</a>.</p>
<p>It gives you the power to iterate/paginate over the entire set of YouTube user&#8217;s/channel&#8217;s videos. In that example let&#8217;s assume you have a protected function doing the reading of a single portion:</p>
<pre lang="php" escaped="true">
protected function _process(Zend_Gdata_YouTube_VideoFeed $videoFeed)
{

    /* @var $entry Zend_Gdata_YouTube_VideoEntry */
    foreach ($videoFeed as $entry) {
        /* @var $published Zend_Gdata_App_Extension_Published */
        $published = $entry-&gt;getPublished();
        $thumbnails = $entry-&gt;getVideoThumbnails();

        // set date format
        $date = new Zend_Date($published-&gt;getText());

        // array
        $tags = $entry-&gt;getVideoTags();

        $data['title'] = $entry-&gt;getVideoTitle();
        $data['description'] = $entry-&gt;getVideoDescription();
        $data['date'] = $date-&gt;get('Y-MM-d hh:mm:ss');
        $data['thumb'] = @$thumbnails[3]['url'];
        $data['id'] = $entry-&gt;getVideoId();
        $data['flash_player'] = $entry-&gt;getFlashPlayerUrl();
        $data['tags'] = implode(',', $tags) . ', ' . $entry-&gt;getVideoCategory();
        // do whatever you want with the data
    }

}
</pre>
<p>The only thing left is to iterate over the &#8220;pages&#8221; of the feed. This can be done with getNextFeed() method.</p>
<pre lang="php" escaped="true">
public function readRssAction()
{
    $userId = 'some_user';
    $client = new Zend_Http_Client();
    $gdata = new Zend_Gdata_YouTube($client, 'my-app', null, $this-&gt;_apiKey);
    $videoFeed = $gdata-&gt;getUserUploads($userId);

    // save the last items
    $this-&gt;_process($videoFeed);

    try {
        while ($videoFeed = $videoFeed-&gt;getNextFeed()) {
            $this-&gt;_process($videoFeed);
        }
    } catch (Zend_Gdata_App_Exception $e) {
        echo $e-&gt;getMessage();
    }
}
</pre>
<p>You&#8217;ll get an exception when there is no more feeds to process!</p>
<p>To combine all this into a single controller and to complete the code here&#8217;s the entire source:</p>
<pre lang="php" escaped="true">
class YoutubeController extends Zend_Controller_Action
{
    protected $_apiKey = 'your_api_key_goes_here';

    protected function _process(Zend_Gdata_YouTube_VideoFeed $videoFeed)
    {

        /* @var $entry Zend_Gdata_YouTube_VideoEntry */
        foreach ($videoFeed as $entry) {
            /* @var $published Zend_Gdata_App_Extension_Published */
            $published = $entry-&gt;getPublished();
            $thumbnails = $entry-&gt;getVideoThumbnails();

            // set date format
            $date = new Zend_Date($published-&gt;getText());

            // array
            $tags = $entry-&gt;getVideoTags();

            $data['title'] = $entry-&gt;getVideoTitle();
            $data['description'] = $entry-&gt;getVideoDescription();
            $data['date'] = $date-&gt;get('Y-MM-d hh:mm:ss');
            $data['thumb'] = @$thumbnails[3]['url'];
            $data['id'] = $entry-&gt;getVideoId();
            $data['flash_player'] = $entry-&gt;getFlashPlayerUrl();
            $data['tags'] = implode(',', $tags) . ', ' . $entry-&gt;getVideoCategory();
            // do whatever you want with the data
        }
    }

    public function readRssAction()
    {
        $userId = 'some_user';
        $client = new Zend_Http_Client();
        $gdata = new Zend_Gdata_YouTube($client, 'my-app', null, $this-&gt;_apiKey);
        $videoFeed = $gdata-&gt;getUserUploads($userId);

        // save the last items
        $this-&gt;_process($videoFeed);

        try {
            while ($videoFeed = $videoFeed-&gt;getNextFeed()) {
                $this-&gt;_process($videoFeed);
            }
        } catch (Zend_Gdata_App_Exception $e) {
            echo $e-&gt;getMessage();
        }
    }
}
</pre>
<p><em><strong>Note:</strong> here you&#8217;ve to substitute the API key with the one you&#8217;ve for your development. </em></p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/03/16/retrieving-youtube-channels-videos-with-zend_gdata_youtube/" rel="bookmark" title="Retrieving YouTube Channel&#8217;s Videos with Zend_Gdata_YouTube">Retrieving YouTube Channel&#8217;s Videos with Zend_Gdata_YouTube </a></li>
<li><a href="/2010/05/21/check-youtube-video-existence-with-zend_gdata_youtube/" rel="bookmark" title="Check YouTube Video Existence with Zend_Gdata_YouTube">Check YouTube Video Existence with Zend_Gdata_YouTube </a></li>
<li><a href="/2010/03/15/force-zend-casting-and-help-the-ide-autocompletion/" rel="bookmark" title="Force Zend Casting and Help the IDE Autocompletion">Force Zend Casting and Help the IDE Autocompletion </a></li>
<li><a href="/2010/04/26/mysql-expressions-in-zend-framework/" rel="bookmark" title="MySQL Expressions in Zend Framework">MySQL Expressions in Zend Framework </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/04/22/iterate-over-youtube-channel-with-zend_gdata_youtube/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
