<?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>GData &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/gdata/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>Check YouTube Video Existence with Zend_Gdata_YouTube</title>
		<link>/2010/05/21/check-youtube-video-existence-with-zend_gdata_youtube/</link>
		<comments>/2010/05/21/check-youtube-video-existence-with-zend_gdata_youtube/#respond</comments>
		<pubDate>Fri, 21 May 2010 07:43:57 +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[Computing]]></category>
		<category><![CDATA[e->]]></category>
		<category><![CDATA[Entertainment/Culture]]></category>
		<category><![CDATA[GData]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[Hypertext Transfer Protocol]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web application frameworks]]></category>
		<category><![CDATA[World Wide Web]]></category>
		<category><![CDATA[YouTube]]></category>
		<category><![CDATA[YouTube Inc]]></category>

		<guid isPermaLink="false">/?p=1531</guid>
		<description><![CDATA[The Video Has Been Removed?! Have you ever seen the famous message on YouTube: &#8220;This video has been removed by the user.&#8221;, but what if you&#8217;re trying to grab that video via the Zend_Gdata_YouTube? That can happen when you&#8217;re reading the feed for a channel or a user&#8217;s list of videos. In the feed everything&#8217;s &#8230; <a href="/2010/05/21/check-youtube-video-existence-with-zend_gdata_youtube/" class="more-link">Continue reading <span class="screen-reader-text">Check YouTube Video Existence 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/04/22/iterate-over-youtube-channel-with-zend_gdata_youtube/" rel="bookmark" title="Iterate over YouTube Channel with Zend_Gdata_YouTube">Iterate over YouTube Channel with Zend_Gdata_YouTube </a></li>
<li><a href="/2010/01/23/youtube-and-vimeo-goes-html5-with-video-tag-usage-catch-them-up/" rel="bookmark" title="YouTube and Vimeo goes HTML5 with video tag usage! Catch them up!">YouTube and Vimeo goes HTML5 with video tag usage! Catch them up! </a></li>
<li><a href="/2011/04/07/use-fopen-to-check-file-availability/" rel="bookmark" title="Use fopen() to Check File Availability?">Use fopen() to Check File Availability? </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>The Video Has Been Removed?!</h2>
<p>Have you ever seen the famous message on <a href="http://youtube.com/">YouTube</a>: &#8220;This video has been removed by the user.&#8221;, but what if you&#8217;re trying to grab that video via the <a href="http://framework.zend.com/manual/en/zend.gdata.youtube.html" target="_blank">Zend_Gdata_YouTube</a>?</p>
<p>That can happen when you&#8217;re reading the feed for a channel or a user&#8217;s list of videos. In the feed everything&#8217;s OK &#8211; once the video is uploaded it appears into the feed. After that the user removes the video and visiting the link from the feed you&#8217;ll get the message above.</p>
<p>Actually what happens when you try to read this &#8220;video entry&#8221; within a Zend Framework&#8217;s application. There must be some way to catch this message?</p>
<h2>Trying to Catch</h2>
<p>The answer is pretty simple! Zend_Gdata_YouTube&#8217;s throwing an exception and it can be easily cached. Here&#8217;s some source code:</p>
<pre lang="php">
$apiKey = 'your_api_key';
$client = new Zend_Http_Client();
$gdata = new Zend_Gdata_YouTube($client, 'my-app', null, $apiKey);
try {
       $gdata->getVideoEntry($video_id);
} catch(Zend_Gdata_App_Exception $e) {
       echo $e->getMessage();
}
</pre>
<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/04/22/iterate-over-youtube-channel-with-zend_gdata_youtube/" rel="bookmark" title="Iterate over YouTube Channel with Zend_Gdata_YouTube">Iterate over YouTube Channel with Zend_Gdata_YouTube </a></li>
<li><a href="/2010/01/23/youtube-and-vimeo-goes-html5-with-video-tag-usage-catch-them-up/" rel="bookmark" title="YouTube and Vimeo goes HTML5 with video tag usage! Catch them up!">YouTube and Vimeo goes HTML5 with video tag usage! Catch them up! </a></li>
<li><a href="/2011/04/07/use-fopen-to-check-file-availability/" rel="bookmark" title="Use fopen() to Check File Availability?">Use fopen() to Check File Availability? </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/05/21/check-youtube-video-existence-with-zend_gdata_youtube/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>
		<item>
		<title>Retrieving YouTube Channel&#8217;s Videos with Zend_Gdata_YouTube</title>
		<link>/2010/03/16/retrieving-youtube-channels-videos-with-zend_gdata_youtube/</link>
		<comments>/2010/03/16/retrieving-youtube-channels-videos-with-zend_gdata_youtube/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 11:53:32 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Application programming interface]]></category>
		<category><![CDATA[Atom]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[GData]]></category>
		<category><![CDATA[Google Inc.]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web application frameworks]]></category>
		<category><![CDATA[World Wide Web]]></category>
		<category><![CDATA[YouTube Inc]]></category>

		<guid isPermaLink="false">/?p=1329</guid>
		<description><![CDATA[Zend_Gdata Zend Framework gives you the possibility to interact with Gdata services, which are provided by most of the Goolge services. You can find more on the docs page of Zend_Gdata. The basic principle is that you can connect a service with you API key, given by Google. What I&#8217;m about to show you is &#8230; <a href="/2010/03/16/retrieving-youtube-channels-videos-with-zend_gdata_youtube/" class="more-link">Continue reading <span class="screen-reader-text">Retrieving YouTube Channel&#8217;s Videos with Zend_Gdata_YouTube</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<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/04/22/iterate-over-youtube-channel-with-zend_gdata_youtube/" rel="bookmark" title="Iterate over YouTube Channel with Zend_Gdata_YouTube">Iterate over YouTube Channel with Zend_Gdata_YouTube </a></li>
<li><a href="/2011/04/13/post-with-zend_http_client/" rel="bookmark" title="POST with Zend_Http_Client">POST with Zend_Http_Client </a></li>
<li><a href="/2010/06/28/send-authenticated-post-request-with-zend_http_client/" rel="bookmark" title="Send Authenticated POST Request with Zend_Http_Client">Send Authenticated POST Request with Zend_Http_Client </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Zend_Gdata</h2>
<p><a title="Zend Framework" href="http://framework.zend.com/" target="_blank">Zend Framework</a> gives you the possibility to interact with <a title="gdata" href="http://code.google.com/apis/gdata/" target="_blank">Gdata</a> services, which are provided by most of the Goolge services. You can find more on the docs page of <a href="http://framework.zend.com/manual/en/zend.gdata.html" target="_blank">Zend_Gdata</a>. The basic principle is that you can connect a service with you API key, given by Google. What I&#8217;m about to show you is how do connect such a service.</p>
<p>In theory Zend_Gdata depends on <a title="Zend_Http_Client" href="http://framework.zend.com/manual/en/zend.http.html" target="_blank">Zend_Http_Client</a> and you&#8217;ve to connect it with an instance of this class.</p>
<pre lang="php">// 1. setup API key
$apiKey = 'your_api_key_here';

// 2. retrieve videos via GData Atom
$client = new Zend_Http_Client();
$gdata = new Zend_Gdata_YouTube(null, 'my-app', null, $apiKey);</pre>
<p>Note that you&#8217;ve to replace your API key in the chunk above.</p>
<p>Now once that you&#8217;ve connected the YouTube service you can iterate through the entries from the video feed.</p>
<pre lang="php">$videoFeed = $gdata->getUserUploads('username');
foreach ($videoFeed as $entry) {
    echo $entry->getTitle();
}</pre>
<p>The thing is that you can modify a bit the code above. As ZF docs says if you don&#8217;t setup a Zend_Http_Client a default with default configuration, so you can omit this and simple write:</p>
<pre lang="php">// 1. setup API key
$apiKey = 'your_api_key_here';

// 2. retrieve videos via GData Atom
$gdata = new Zend_Gdata_YouTube(null, 'my-app', null, $apiKey);</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<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/04/22/iterate-over-youtube-channel-with-zend_gdata_youtube/" rel="bookmark" title="Iterate over YouTube Channel with Zend_Gdata_YouTube">Iterate over YouTube Channel with Zend_Gdata_YouTube </a></li>
<li><a href="/2011/04/13/post-with-zend_http_client/" rel="bookmark" title="POST with Zend_Http_Client">POST with Zend_Http_Client </a></li>
<li><a href="/2010/06/28/send-authenticated-post-request-with-zend_http_client/" rel="bookmark" title="Send Authenticated POST Request with Zend_Http_Client">Send Authenticated POST Request with Zend_Http_Client </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/03/16/retrieving-youtube-channels-videos-with-zend_gdata_youtube/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>
