<?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>Stubbleblog &#187; php</title>
	<atom:link href="http://www.stubbleblog.com/index.php/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stubbleblog.com</link>
	<description>A curious nerd.</description>
	<lastBuildDate>Mon, 02 Jan 2012 18:30:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>YouTube API How-To</title>
		<link>http://www.stubbleblog.com/index.php/2006/11/youtube-api-how/</link>
		<comments>http://www.stubbleblog.com/index.php/2006/11/youtube-api-how/#comments</comments>
		<pubDate>Wed, 08 Nov 2006 22:46:57 +0000</pubDate>
		<dc:creator>Tony Stubblebine</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[mashup]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://www.stubbleblog.com/wp/?p=134</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<h2>What is it</h2>
<p>The <a href="http://www.youtube.com/dev">YouTube API</a> lets you search for videos and display them on your site. For example, I use the API to pull videos tagged dance and display them on <a href="http://www.ratemydancemoves.com">Rate My Dance Moves</a>. The YouTube API is currently the 10th most popular API on ProgrammableWeb with <a href="http://www.programmableweb.com/api/YouTube/mashups">46 mashups</a>.</p>
<p>To get started you need to sign up for a <a href="http://www.youtube.com/signup?next=my_profile_dev">developer account</a>. That will give you the developer id required to use the API.</p>
<h2>Using the API</h2>
<p>The major API methods are for retrieving lists of videos, which you can do by <a href="http://www.youtube.com/dev_api_ref?m=youtube.videos.list_by_tag">tag</a>, <a href="http://www.youtube.com/dev_api_ref?m=youtube.videos.list_by_user">user</a>, <a href="http://www.youtube.com/dev_api_ref?m=youtube.users.list_favorite_videos">user favorites</a>, and <a href="http://www.youtube.com/dev_api_ref?m=youtube.videos.list_featured">featured</a>. The information returned from the list methods is usually enough to display a video on your site. All you have to do is plug the video id into the web snippit below.</p>
<pre>
<code>
&lt;object width="425" height="350">
&lt;param name="movie" value="http://www.youtube.com/v/<strong>ID</strong>&#038;autoplay=1">
&lt;/param>
&lt;embed src="http://www.youtube.com/v/<strong>ID</strong>&#038;autoplay=1"
type="application/x-shockwave-flash" width="425" height="350">&lt;/embed>
&lt;/object>
</code>
</pre>
<p>Most of the information you need is in the video list methods. However, if you want a list of comments or channels for the video you&#8217;ll need to call the <a href="http://www.youtube.com/dev_api_ref?m=youtube.videos.get_details">get_details</a> method.</p>
<p>One complaint I had with <code>list_by_tag</code> is that the results come back ordered by relevance rather than recency. That means if you want to build a self-updating site you need to either regularly crawl the entire result set (results are paged) or sit on one of the  <a href="http://www.youtube.com/dev_api_ref?m=youtube.videos.list_by_tag">RSS Feeds.</a></p>
<h2>API Wrappers</h2>
<p>There are good libraries  for using the YouTube API with Perl, Ruby, and .NET. If you&#8217;re using another language, say Java, PHP or Python, you&#8217;ll have to write some code yourself. I&#8217;ve included links to example PHP and Python code and listed an example Ruby program that you can use as a template for whatever language you&#8217;re writing in.</p>
<p>There&#8217;s two competing Perl modules, but Hironori Yoshida&#8217;s <a href="http://search.cpan.org/author/YOSHIDA/WebService-YouTube-0.04/lib/WebService/YouTube.pm">WebService::YouTube </a> and <a href="http://search.cpan.org/author/YOSHIDA/WebService-YouTube-0.04/lib/WebService/YouTube/Feeds.pm">WebService::Youtube::Feeds </a> seem best based on the recent development activity and strength of documentation. His is the only wrapper which includes support for the feeds, nice since the feeds have functionality thats not in the API (namely list by recency).</p>
<p>Shane Vitarana released a <a href="http://shanesbrain.net/articles/2006/09/28/a-ruby-interface-to-the-youtube-api">YouTube Ruby Gem</a> after I&#8217;d built RateMyDanceMoves. Too bad, since it seems like the most polished of all the wrappers.</p>
<p>Eamonn Flynn has a <a href="http://www.eamonnflynn.net/YouTubeDotNet/YouTubeApi.htm">.NET wrapper for the YouTube API.</a></p>
<p>There doesn&#8217;t seem to be a packaged PHP library but these two tutorials from waxjelly should be enough to get you started. <br />
<a href="http://www.waxjelly.com/2006/08/28/simple-php-script-using-the-youtube-api-with-pagination-part-1/">Simple PHP Script Using the YouTube API with Pagination</a><br />
<a href="http://www.waxjelly.com/2006/08/29/a-more-complex-php-script-using-the-youtube-api-with-video-details-part-2/">A More Complex PHP Script Using the YouTube API with Pagination.</a></p>
<p>ThinkHole labs has some <a href="http://thinkhole.org/wp/2006/01/09/the-youtube-api-and-python/">example YouTube API code for Python users</a>. Apparently using the API can be as simple as passing a dictionary to YouTube&#8217;s XML-RPC interface.</p>
<h2>Code Example</h2>
<p>I&#8217;d written my own code before the Ruby library came out. I want to show it here so you can see how simple writing your own code would be.</p>
<p><pre>
<code>
#!/usr/bin/env ruby
require 'open-uri'

tag = "dancing"
per_page = "100"
def_id = "YOUR_DEV_ID_HERE"
url = "http://www.youtube.com/api2_rest?" \
+ "method=youtube.videos.list_by_tag" \
+ "&#038;tag=#{tag}&#038;per_page=#{per_page}&#038;dev_id=#{dev_id}&#038;page=1"

open(url) do |f|
xml = f.read
end

doc = REXML::Document.new(xml)

elements = doc.root.get_elements("//video")
elements.each do |v|
puts v.get_elements("id").first.get_text.to_s
puts v.get_elements("title").first.get_text.to_s
puts v.get_elements("tags").first.get_text.to_s
puts v.get_elements("thumbnail_url").first.get_text.to_s
end
</code>
</pre>
</p>
<h2>More Info</h2>
<p><a href="http://www.quickonlinetips.com/archives/2006/10/the-amazing-youtube-tools-collection">The Amazing YouTube Tools Collection</a> has a long collection of YouTube tools, mashups, and plugins. </p>
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://www.stubbleblog.com/index.php/2006/12/using-the-sales/' title='Using the Salesforce API'>Using the Salesforce API</a></li>
<li><a href='http://www.stubbleblog.com/index.php/2006/11/introduction-to/' title='Introduction to Salesforce AppExchange'>Introduction to Salesforce AppExchange</a></li>
<li><a href='http://www.stubbleblog.com/index.php/2006/09/quotes-on-your/' title='Quotes On Your Phone'>Quotes On Your Phone</a></li>
<li><a href='http://www.stubbleblog.com/index.php/2005/07/online-ruby-tra/' title='Online Ruby Training'>Online Ruby Training</a></li>
<li><a href='http://www.stubbleblog.com/index.php/2011/04/writing-rails-engines-getting-started/' title='Writing Rails Engines #1: Getting Started'>Writing Rails Engines #1: Getting Started</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.stubbleblog.com/index.php/2006/11/youtube-api-how/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Online Ruby Training</title>
		<link>http://www.stubbleblog.com/index.php/2005/07/online-ruby-tra/</link>
		<comments>http://www.stubbleblog.com/index.php/2005/07/online-ruby-tra/#comments</comments>
		<pubDate>Sun, 17 Jul 2005 23:44:06 +0000</pubDate>
		<dc:creator>Tony Stubblebine</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[training]]></category>

		<guid isPermaLink="false">http://www.stubbleblog.com/wp/?p=41</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>Scott Gray, the founder of UserActive, was talking to me about how important hands-on learning is to any sort of training. We talked a little bit about me writing a Ruby or Ruby on Rails class for UserActive and I wanted to get a sense for how the classes work.</p>
<p>I started with <a href="http://www.useractive.com/courses/php.php3?course=php&#038;partnerid=1">Learning PHP</a>. The class is self-paced, you read lab material and type code into an integrated programming sandbox. Then at the end of the lab you take a short test or do a short programming assignment. A grader looks over your work and gives you feedback.</p>
<p>The hands-on piece works! The programming sandbox is really useful and gives you a chance to immediately hack on whatever the lab is teaching you.</p>
<p>The Learning PHP class was geared towards people new to programming or new to the web, for instance there&#8217;s a &#8220;What is a variable&#8221; section. That got me thinking, how would I gear a Ruby on Rails tutorial, towards beginners or towards experts.</p>
<p>Rails has a real following among high level programmers because it abstracts a lot of menial details while also offering enough flexibility to override the defaults. It looks like a Java killer so it&#8217;s ending up in a lot of flame wars about how enterprise ready it is.</p>
<p>People haven&#8217;t explored how easy it is for designers or part-time programmers to use. Is it a PHP killer? Well, you don&#8217;t need to know any Ruby to get a Rails application up. That&#8217;s a good sign. You usually don&#8217;t need to know any SQL. That&#8217;s another good sign.</p>
<p>I wonder if the Model-View-Controller model is too abstract for most non-programmers? In my experience, people will do fine. Our web producers work with a much more abstracted system.</p>
<p>In any case, I think the online lab + sandbox model that UserActive offers would be a great introduction to people who probably aren&#8217;t going to go through the trouble of installing Rails themselves.</p>
<p>In the mean time, here&#8217;s the full <a href="http://www.useractive.com/courses/php.php3?course=php&#038;partnerid=1">UserActive catalog</a>.</p>
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://www.stubbleblog.com/index.php/2011/04/writing-rails-engines-getting-started/' title='Writing Rails Engines #1: Getting Started'>Writing Rails Engines #1: Getting Started</a></li>
<li><a href='http://www.stubbleblog.com/index.php/2006/11/youtube-api-how/' title='YouTube API How-To'>YouTube API How-To</a></li>
<li><a href='http://www.stubbleblog.com/index.php/2006/01/etel-2006-day-1/' title='ETel 2006: Day 1.'>ETel 2006: Day 1.</a></li>
<li><a href='http://www.stubbleblog.com/index.php/2005/07/rubyrailsfedora/' title='Ruby/Rails/Fedora/Apache2'>Ruby/Rails/Fedora/Apache2</a></li>
<li><a href='http://www.stubbleblog.com/index.php/2005/06/ubuntu-on-rails/' title='Ubuntu on Rails: Getting up to speed with Ruby on Rails and Ubuntu'>Ubuntu on Rails: Getting up to speed with Ruby on Rails and Ubuntu</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.stubbleblog.com/index.php/2005/07/online-ruby-tra/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Book Haul</title>
		<link>http://www.stubbleblog.com/index.php/2005/06/php-book-haul/</link>
		<comments>http://www.stubbleblog.com/index.php/2005/06/php-book-haul/#comments</comments>
		<pubDate>Tue, 21 Jun 2005 18:04:54 +0000</pubDate>
		<dc:creator>Tony Stubblebine</dc:creator>
				<category><![CDATA[book]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.stubbleblog.com/wp/?p=29</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p>Current work project is a social network a la Friendster or Linkedin to be launched at OSCON. It&#8217;s written in PHP. I need to do the <a href="http://www.oreillynet.com/pub/wlg/4692">single sign-on</a> integration but I&#8217;ve never written in PHP before. Thankfully there&#8217;s O&#8217;Reilly&#8217;s free book perk.</p>
<p><a href="http://www.oreilly.com/catalog/phpckbk">PHP Cookbook</a><br />
<a href="http://www.oreilly.com/catalog/progphp">Programming PHP</a><br />
<a href="http://www.oreilly.com/catalog/webdbapps2">Web Database Applications with PHP and MySQL</a></p>
<p>The cookbook&#8217;s been the most valuable from this haul.</p>
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://www.stubbleblog.com/index.php/2007/07/regular-express/' title='Regular Expression Pocket Reference, 2nd Edition'>Regular Expression Pocket Reference, 2nd Edition</a></li>
<li><a href='http://www.stubbleblog.com/index.php/2006/11/youtube-api-how/' title='YouTube API How-To'>YouTube API How-To</a></li>
<li><a href='http://www.stubbleblog.com/index.php/2006/06/nice-review-of/' title='Nice Review of Regular Expression Pocket Reference'>Nice Review of Regular Expression Pocket Reference</a></li>
<li><a href='http://www.stubbleblog.com/index.php/2005/07/online-ruby-tra/' title='Online Ruby Training'>Online Ruby Training</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.stubbleblog.com/index.php/2005/06/php-book-haul/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  www.stubbleblog.com/index.php/tag/php/feed/ ) in 0.30802 seconds, on Feb 11th, 2012 at 7:40 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 18th, 2012 at 7:40 am UTC -->
