<?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>Dark Crimson Blog &#187; Tutorials</title>
	<atom:link href="http://blog.darkcrimson.com/tag/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.darkcrimson.com</link>
	<description>The Blog of Ben Lister</description>
	<lastBuildDate>Sat, 17 Jul 2010 22:54:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Practical CSS3 for Web Designers</title>
		<link>http://blog.darkcrimson.com/2010/04/practical-css3/</link>
		<comments>http://blog.darkcrimson.com/2010/04/practical-css3/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 21:31:11 +0000</pubDate>
		<dc:creator>Ben Lister</dc:creator>
				<category><![CDATA[CSS3]]></category>
		<category><![CDATA[CSS3 Border Image]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.darkcrimson.com/?p=196</guid>
		<description><![CDATA[Designers have been using basic CSS3 techniques to enhance their designs for several years now, but cross-browser incompatibilities and lack of practical examples have slowed its progression in the mainstream design world. In this tutorial, I explore and demonstrate some of the more practical aspects of CSS3 and provide realistic examples, resources, advise and a [...]]]></description>
			<content:encoded><![CDATA[<p>Designers have been using basic CSS3 techniques to enhance their designs for several years now, but cross-browser incompatibilities and lack of practical examples have slowed its progression in the mainstream design world. In this tutorial, I explore and demonstrate some of the more practical aspects of CSS3 and provide realistic examples, resources, advise and a compatibility guide.</p>
<p><span id="more-196"></span></p>
<h3 class="blog_ttl">The demo page showcases a number of CSS3 techniques including:</h3>
<ul class="in_post">
<li>Gradients (Radial and Linear)</li>
<li>&#8220;Rounded&#8221; Border Images</li>
<li>Border Radius</li>
<li>Drop Shadows (Box and Text)</li>
<li>Transforms</li>
<li>Keyframe Animations</li>
<li>Transitions</li>
<li>Image Masking</li>
<li>:target Pseudo Selector</li>
<li>Multiple Backgrounds</li>
<li>CSS Columns</li>
</ul>
<h3 class="blog_ttl">Examples in the demo include:</h3>
<ul class="in_post">
<li>Image gallery with randomized CSS transitions (supplemented with jQuery)</li>
<li>Image-less 3D Bar Chart</li>
<li>Pure HTML / CSS Accordion links</li>
<li>Navigation with  CSS animated hover effects</li>
<li>jQuery powered &#8220;View Mode&#8221; with CSS3 visual enhancements</li>
</ul>
<p>
<strong><br />
 After exploring the demo use the &#8220;CSS View Mode&#8221; feature to see example code, my comments and suggested resources / examples for each example.</strong>
</p>
<h3 class="blog_ttl">The demo:</h3>
<p><a href="http://blog.darkcrimson.com/samples/css3/" class="view_demo ext">View Demo</a><a href="http://blog.darkcrimson.com/samples/css3/darkcrimson_css3_demo.zip" class="view_source">Download Source</a><br />
<br class="clearall "></p>
<h3 class="blog_ttl">Final thoughts</h3>
<p>Although the upcoming FireFox <a href="http://www.downloadsquad.com/2010/05/11/firefox-3-7-will-become-4-0-firefox-4-with-updated-gecko-co/" target="_blank">3.7/ 4.0</a> is <a href="https://developer.mozilla.org/en/CSS/-moz-transition" target="_blank">said to include support for CSS transitions</a>, you will need to use a Webkit browser for now to see some of the advanced examples. I recommend updating to the latest version for full support.  I designed this demo for Webkit, Firefox 3.6+ and Opera 10.5.3 and have intentionally used browser vendor prefixes accordingly.  There are, of course, other browsers which offer (limited) support of CSS3 properties but this demo is geared towards mainstream browsers (that is my way of saying don&#8217;t use IE on this demo).</p>
<div style="text-align: center; margin: 20px auto; width: 75%; padding: 8px; background: none repeat scroll 0% 0% rgb(79, 0, 0);"><strong>UPDATE 5/28/10:</strong> Added Opera support to demo page, see my comment from 5/28 below.</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.darkcrimson.com/2010/04/practical-css3/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Mastering the Flickr API with PHP and cURL</title>
		<link>http://blog.darkcrimson.com/2009/11/mastering-the-flickr-api-with-php-and-curl/</link>
		<comments>http://blog.darkcrimson.com/2009/11/mastering-the-flickr-api-with-php-and-curl/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 04:48:55 +0000</pubDate>
		<dc:creator>Ben Lister</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[CURL]]></category>
		<category><![CDATA[Flickr]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://blog.darkcrimson.com/?p=34</guid>
		<description><![CDATA[The Flickr API is a very powerful and easy to use way to put photos on your website without having to worry about bandwidth or server performance issues. This tutorial will cover how to make an API call for a photoset and then format and display a list of ~100px thumbnail images in unordered list.
Getting [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.flickr.com/services/api/" class="ext">Flickr API</a> is a very powerful and easy to use way to put photos on your website without having to worry about bandwidth or server performance issues. This tutorial will cover how to make an API call for a photoset and then format and display a list of ~100px thumbnail images in unordered list.<span id="more-34"></span></p>
<h3 class="blog_ttl">Getting An API Key</h3>
<p>To get started with the Flickr API, you need to sign into Flickr and <a href="http://www.flickr.com/services/apps/create/apply/" class="ext">Apply for an API key</a>. After you register for the API Key, you should browse through <a href="http://www.flickr.com/services/api/" target="_self">Flickr&#8217;s API page</a> to see some examples of what is possible. As you will see, there are quite a few methods listed which might seem a bit daunting. The nice thing is all of the provided methods are well documented and after one successful implementation, working through the rest is fairly repetitious.</p>
<h3 class="blog_ttl">Hot, Steamy PHP Action</h3>
<p>We will be using <a href="http://php.net/manual/en/book.curl.php" class="ext"><code>cURL</code></a> to get the data from Flickr. Some might prefer another method such as PHP&#8217;s <a href="http://php.net/manual/en/function.file-get-contents.php" class="ext"><code>file_get_contents</code></a>, there are advantages to both but you can read a book (or <a href="http://www.google.com/search?q=curl+vs+file_get_contents" class="ext">Google</a>) for more information on this.</p>
<p>Getting started with the cURL request:</p>
<pre name="code" class="php">$params = array(
	'api_key'	=&gt; 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
	'method'	=&gt; 'flickr.photosets.getPhotos',
	'photoset_id'	=&gt; '72157622566216264',
	'extras'	=> 'original_format',
	'format'	=&gt; 'php_serial'
);
$encoded_params = array();
foreach ($params as $k => $v){ $encoded_params[] = urlencode($k).'='.urlencode($v); }
</pre>
<p>In the code above we first put the API key and then choose the Method (which is listed on the Flickr API page link listed earlier in the tutorial). Next we specify the photo set id which for this example is the set seen in <a href="http://darkcrimson.com/portfolio" class="ext">my Portfolio</a>. The parameters for &#8220;Extras&#8221; depend on the Method used and desired options and range from date uploaded to author to tags. For this example we will be calling &#8220;original_format&#8221; which will pull a link to the full size version of the image. Finally, we choose &#8220;php_serial&#8221; as the format which will return a <a href="http://php.net/manual/en/function.serialize.php" class="ext">serialized</a> PHP string with the data (Alternatively you could use JSON but we can save that fun for a JavaScript tutorial).</p>
<p><em>Please note: </em>to use the &#8220;original_format&#8221; parameter you will need to be a <a href="http://www.flickr.com/upgrade/" class="ext">Flickr Pro</a> member.</p>
<pre name="code" class="php">$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, 'http://api.flickr.com/services/rest/?'.implode('&amp;', $encoded_params));
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);

 $rsp_obj = unserialize($file_contents);</pre>
<p>The code above makes the cURL call to Flickr&#8217;s API with the data we set in the previous code block, <code>unserializes</code> the <code>cURL</code> object&#8217;s returned data and creates a new Array called <code>$rsp_obj.</code></p>
<p>Let&#8217;s pause and take a look at some of the data that was returned with a little <code>print_r($_rsp_ojb)</code> action:</p>
<pre name="code" class="php">Array
(
    [photoset] =&gt; Array
        (
            [id] =&gt; 72157622566216264
            [primary] =&gt; 4003748546
            [owner] =&gt; 7332638@N08
            [ownername] =&gt; benlister
            [photo] =&gt; Array
                (
                    [0] =&gt; Array
                        (
                            [id] =&gt; 4003748546
                            [secret] =&gt; 69b188c174
                            [server] =&gt; 2643
                            [farm] =&gt; 3
                            [title] =&gt; Chicago (Montrose Harbor)
                            [isprimary] =&gt; 1
                            [originalsecret] =&gt; 728e01b6c1
                            [originalformat] =&gt; jpg
                        )

                    [1] =&gt; Array
                        (
                            [id] =&gt; 4052220478
                            [secret] =&gt; ec5e79cbbe
                            [server] =&gt; 2780
                            [farm] =&gt; 3
                            [title] =&gt; Seattle Sci-Fi Museum Exterior
                            [isprimary] =&gt; 0
                            [originalsecret] =&gt; 625519fc32
                            [originalformat] =&gt; jpg
                        )

..............</pre>
<p>The array output above tells us pretty  everything we will need to create links to all sizes of each photo in the set. To display each photo in the photo set we first need to step into the <code>[photo]</code> section of  the <code>[photoset]</code> array.</p>
<pre name="code" class="php">if ($rsp_obj['stat'] == 'ok') {

		$photos = $rsp_obj["photoset"]["photo"];

	echo "
<ul>";

	foreach($photos as $photo) {

               $farm              = $photo['farm'];
               $server            = $photo['server'];
               $photo_id          = $photo['id'];
               $secret            = $photo['secret'];
               $photo_title       = $photo['title'];
<li><img /*SEE CODE BLOCK BELOW/* /></li>

	}
	  echo "</li>
</ul>

";

	} else {
            echo "Error getting photos";
       }</pre>
<p>     [note: the codeblock is not displaying the following img src line correctly in the line above so it has been moved below]</p>
<pre name="code" class="php">src="http://farm'.$photo['farm'].'.static.flickr.com/'.$photo['server'].'/'.$photo['id'].'_'.$photo['secret'].'_t.jpg" alt="'.$photo['title'].'"</pre>
<p>The code above first checks to see if the data was returned ok before trying to iterate through the array. Once we have verified that we have the data, we name the <code>[photo]</code> array more intuitively.</p>
<h3 class="blog_ttl">Putting it all together</h3>
<p>Let&#8217;s break down the URL piece by piece to better understand whats going on: For example if the URL is as follows:</p>
<p>http://farm<strong>3</strong>.static.flickr.com/<strong>2421</strong>/<strong>4002906997</strong>_<strong>5e9de854c6</strong>_<strong>t</strong>.jpg</p>
<ul>
<li>$photo["farm"] = 3</li>
<li>$photo["server"] = 2421</li>
<li>$photo["id"] = 4002906997</li>
<li>$photo["secret"] = 5e9de854c6</li>
<li>_s = 75px square thumbnail</li>
<li>_t = 100px thumbnail</li>
<li>_m = 240px thumbnail</li>
</ul>
<p><strong>To get the &#8220;normal&#8221; 500px image, use the sequence above minus the &#8220;underscore letter&#8221; ending.</strong></p>
<p><strong>To get the full &#8220;original size&#8221; takes a bit more work:</strong></p>
<p><strong><br />
</strong></p>
<pre name="code" class="php">src="http://farm'.$photo['farm'].'.static.flickr.com/'.$photo['server'].'/'.$photo['id'].'_'.$photo['originalsecret'].'_o.jpg"</pre>
<p><strong>UPDATE 7/10:</strong> I realized that I haven&#8217;t updated this in a while and wanted to share a much easier way to get the original full-size image:</p>
<pre name="code" class="php">
	// In the params array, replace:
	'extras'	=> 'original_format',

	// With:
	'extras'	=> 'url_o',

	//And to call the image:

	src="'.$photo['url_o'].'"
</pre>
<p>You should now be able to create a sample image page from a photo set in all sizes. You can also apply these principles to almost any of Flickr&#8217;s API Methods to achieve more customized results. Enjoy!</p>
<p><a class="view_tutorial ext" href="http://darkcrimson.com/flickr_example.php">View thumbnail Sample Page</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.darkcrimson.com/2009/11/mastering-the-flickr-api-with-php-and-curl/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
