<?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>su.percilio.us &#187; code</title>
	<atom:link href="http://su.percilio.us/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://su.percilio.us</link>
	<description>Haughtily disdainful or contemptuous</description>
	<lastBuildDate>Tue, 06 Apr 2010 15:58:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Convio Web Services in Python and PHP</title>
		<link>http://su.percilio.us/2009/10/convio-web-services-in-python-and-php/</link>
		<comments>http://su.percilio.us/2009/10/convio-web-services-in-python-and-php/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 17:42:20 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[Nerdities]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[convio]]></category>
		<category><![CDATA[cws]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[suds]]></category>

		<guid isPermaLink="false">http://su.percilio.us/?p=137</guid>
		<description><![CDATA[Expanding on my last post about being able to successfully connect to Convio Web Services in three lines, I&#8217;d like to get a little more in depth and actually construct the necessary SOAP headers and make a simple call. I&#8217;ve written a small PHP implementation as well. I was able to make a successful log [...]]]></description>
			<content:encoded><![CDATA[<p>Expanding on my last post about being able to successfully connect to Convio Web Services in three lines, I&#8217;d like to get a little more in depth and actually construct the necessary SOAP headers and make a simple call. I&#8217;ve written a small PHP implementation as well. I was able to make a successful log in to CWS in just <em>2 lines</em> of PHP code!</p>
<div style="text-align: center; margin-bottom: 10px"><img class="size-medium wp-image-117" style="border: 1px solid #ccc; padding: 5px; margin: 0 auto; background: none" src="http://su.percilio.us/wp-content/uploads/2009/10/convio_logo-300x160.gif" alt="Convio Logo" title="Convio Logo" width="300" height="160"  /></div>
<p>Now, as far as CWS goes, Python and PHP may not instantly be an obvious choice as far as languages go, mainly because they are both largely scripting languages. CWS is mainly for robust data syncing operations and those tasks generally go to languages like Java or C#, however, I&#8217;m a high level language guy, so I  go with what I know. Also, Python and PHP both make SOAP exceedingly easy to work with, so there&#8217;s no real reason why you can&#8217;t, with a bit of discipline, write a perfectly excellent and robust data sync operation in either of these languages &#8230; especially Python.</p>
<p>So, here are my examples. They are exceedingly simple and easy once again. The Python example leverages suds once again and the PHP example is using PHP&#8217;s pretty impressive built in SOAP library. Each example shows you how to create the SOAP client using the Convio WSDL, make a successful log in to CWS, create a valid session header for subsequent calls, and how to make a call that grabs the number of constituents that have been added to the Convio database.</p>
<p>If you find either of these examples helpful, please let me know! Keep in mind these are just functional examples. There is no proper error handling or any sort of architecture here; they are just some bare bones examples on how to get data from CWS.</p>
<p><strong>Python</strong></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> suds.<span style="color: black;">client</span> <span style="color: #ff7700;font-weight:bold;">import</span> Client
&nbsp;
<span style="color: #808080; font-style: italic;"># Load the WSDL                                                                                                                                                                                                                                </span>
client = Client<span style="color: black;">&#40;</span><span style="color: #483d8b;">'https://secureX.convio.net/1.0/CLIENT/wsdl'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Log in to CWS                                                                                                                                                                                                                                </span>
login = client.<span style="color: black;">service</span>.<span style="color: black;">Login</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'apiadmin'</span>, <span style="color: #483d8b;">'password'</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Set the session header                                                                                                                                                                                                                       </span>
session = client.<span style="color: black;">factory</span>.<span style="color: black;">create</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Session'</span><span style="color: black;">&#41;</span>
session.<span style="color: black;">SessionId</span> = login.<span style="color: black;">SessionId</span>
client.<span style="color: black;">set_options</span><span style="color: black;">&#40;</span>soapheaders=session<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Get the number of constituents added since last sync                                                                                                                                                                                         </span>
data = <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span>PartitionId=<span style="color: #ff4500;">1001</span>, RecordType=<span style="color: #483d8b;">'Constituent'</span>, PageSize=<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
response = client.<span style="color: black;">service</span>.<span style="color: black;">GetIncrementalInsertsCount</span><span style="color: black;">&#40;</span><span style="color: #66cc66;">**</span>data<span style="color: black;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># Show the number of constituents added                                                                                                                                                                                                        </span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'%d constituents have been added since the last sync.'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span>response.<span style="color: black;">RecordCount</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p><strong>PHP</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Load the WSDL                                                                                                                                                                                                                               </span>
<span style="color: #000088;">$client</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SoapClient<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'https://secureX.convio.net/1.0/CLIENT/wsdl'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Log in to CWS                                                                                                                                                                                                                               </span>
<span style="color: #000088;">$login</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Login</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'UserName'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'apiadmin'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Password'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Set the session header                                                                                                                                                                                                                      </span>
<span style="color: #000088;">$headerBody</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SessionId'</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$login</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">SessionId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$header</span>     <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SoapHeader<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'urn:soap.convio.com'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Session'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$headerBody</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span>__setSoapHeaders<span style="color: #009900;">&#40;</span><span style="color: #000088;">$header</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Get the number of constituents added since last sync                                                                                                                                                                                        </span>
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span>
<span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'PartitionId'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1001</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'RecordType'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Constituent'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'PageSize'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">GetIncrementalInsertsCount</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Show the number of constituents added                                                                                                                                                                                                       </span>
<span style="color: #b1b100;">print</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #009933; font-weight: bold;">%d</span> constituents have been added since the last sync<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> <span style="color: #000088;">$response</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">RecordCount</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fsu.percilio.us%2F2009%2F10%2Fconvio-web-services-in-python-and-php%2F';
  addthis_title  = 'Convio+Web+Services+in+Python+and+PHP';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://su.percilio.us/2009/10/convio-web-services-in-python-and-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Log In to Convio Web Services with three lines of Python</title>
		<link>http://su.percilio.us/2009/10/log-in-to-convio-web-services-with-three-lines-of-python/</link>
		<comments>http://su.percilio.us/2009/10/log-in-to-convio-web-services-with-three-lines-of-python/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 19:16:04 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[Nerdities]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[convio]]></category>
		<category><![CDATA[cws]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[suds]]></category>

		<guid isPermaLink="false">http://su.percilio.us/?p=130</guid>
		<description><![CDATA[I was on the look out for a good SOAP library for Python now that I am the new Convio &#8220;API Guy.&#8221; In my search I discovered this library: Suds To test it out I tried making successful connection to Convio Web Services. 1 2 3 from suds.client import Client client = Client&#40;'https://secureX.convio.net/1.0/CLIENT/wsdl'&#41; result = [...]]]></description>
			<content:encoded><![CDATA[<p>I was on the look out for a good SOAP library for Python now that I am the new Convio &#8220;API Guy.&#8221;</p>
<div style="text-align: center; margin-bottom: 10px"><img class="size-medium wp-image-117" style="border: 1px solid #ccc; padding: 5px; margin: 0 auto; background: none" src="http://su.percilio.us/wp-content/uploads/2009/10/convio_logo-300x160.gif" alt="Convio Logo" title="Convio Logo" width="300" height="160"  /></div>
<p>In my search I discovered this library:</p>
<p><a href="https://fedorahosted.org/suds/" target="_blank">Suds</a></p>
<p>To test it out I tried making successful connection to Convio Web Services.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> suds.<span style="color: black;">client</span> <span style="color: #ff7700;font-weight:bold;">import</span> Client
client = Client<span style="color: black;">&#40;</span><span style="color: #483d8b;">'https://secureX.convio.net/1.0/CLIENT/wsdl'</span><span style="color: black;">&#41;</span>
result = client.<span style="color: black;">service</span>.<span style="color: black;">Login</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'apiadmin'</span>, <span style="color: #483d8b;">'password'</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Boom. Straight in, no fuss no muss. Pretty impressive. I&#8217;m going to play with Suds and CWS a bit more to see if there is actually a robust Python based syncing application that can be made here. I&#8217;m led to believe Suds is not great for creating SOAP servers, but it makes for a very &#8220;Pythonic&#8221; and easy to understand way to create a SOAP client.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fsu.percilio.us%2F2009%2F10%2Flog-in-to-convio-web-services-with-three-lines-of-python%2F';
  addthis_title  = 'Log+In+to+Convio+Web+Services+with+three+lines+of+Python';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://su.percilio.us/2009/10/log-in-to-convio-web-services-with-three-lines-of-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Library For Convio Open API</title>
		<link>http://su.percilio.us/2009/10/php-library-for-convio-open-api/</link>
		<comments>http://su.percilio.us/2009/10/php-library-for-convio-open-api/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 17:12:08 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[Nerdities]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[convio]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://su.percilio.us/?p=118</guid>
		<description><![CDATA[If any of you out there use Convio for your non-profit&#8217;s on-line presence, ie website, donations, email campaigns, I&#8217;ve created a PHP library for connecting to their Open API. I say it&#8217;s a &#8220;Library&#8221;&#8230; it&#8217;s really just a single wrapper file that aids in connecting to, making call to, and handling responses from, the Convio [...]]]></description>
			<content:encoded><![CDATA[<p>If any of you out there use <a href="http://convio.com" target="_blank">Convio</a> for your non-profit&#8217;s on-line presence, ie website, donations, email campaigns, I&#8217;ve created a PHP library for connecting to their Open API.</p>
<div style="text-align: center; margin-bottom: 10px"><img class="size-medium wp-image-117" style="border: 1px solid #ccc; padding: 5px; margin: 0 auto; background: none" src="http://su.percilio.us/wp-content/uploads/2009/10/convio_logo-300x160.gif" alt="Convio Logo" title="Convio Logo" width="300" height="160"  /></div>
<p>I say it&#8217;s a &#8220;Library&#8221;&#8230; it&#8217;s really just a single wrapper file that aids in connecting to, making call to, and handling responses from, the Convio Open APIs.</p>
<p>There&#8217;s no documentation to speak of, but the two files included in the zip archive are pretty solidly commented, so you will probably be able to get a lot from them. The two files included in the zip are the library file itself and an example of how to implement it.</p>
<p>If you end up using it, let me know what you think!</p>
<p><strong><a href="http://su.percilio.us/files/convio-api-php.zip">Download the PHP Library for Convio Open API</a></strong></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fsu.percilio.us%2F2009%2F10%2Fphp-library-for-convio-open-api%2F';
  addthis_title  = 'PHP+Library+For+Convio+Open+API';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://su.percilio.us/2009/10/php-library-for-convio-open-api/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>JProQuiz: Javascript Quiz Software</title>
		<link>http://su.percilio.us/2008/08/jproquiz-javascript-quiz-software/</link>
		<comments>http://su.percilio.us/2008/08/jproquiz-javascript-quiz-software/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 21:05:43 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[Nerdities]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[scriptaculous]]></category>

		<guid isPermaLink="false">http://su.percilio.us/?p=43</guid>
		<description><![CDATA[A couple of weeks ago a friend asked me if I&#8217;d be interested doing a little contract work for the company he works for. The project was to come up with an on line quiz, mimicking that of FreeRice.com. Reasonably simple I thought, so I figured it might be good for a laugh and few [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago a friend asked me if I&#8217;d be interested doing a little contract work for the company he works for. The project was to come up with an on line quiz, mimicking that of <a title="FreeRice.com" href="http://freerice.com" target="_blank">FreeRice.com</a>. Reasonably simple I thought, so I figured it might be good for a laugh and few pennies. The caveat being, if possible, for it to be entirely browser-side, as his company&#8217;s software did not support server-side code. Now <em>that</em> sounded interesting.</p>
<p>Being the impulsive code-monkey that I am, instead of waiting for the finalization of my contract to come through, I simply went ahead and coded the whole thing. Naturally, they decided to give this to someone internal and not hire me, so their loss is your gain. I didn&#8217;t have anything to do with this software after I&#8217;d written it, so I figured I would publish it here on my blog for the whole world to use.</p>
<p>The software itself is incredibly simple. Actually, I hesitate to call it software at all. It&#8217;s just one Javascript class file, some specifically name HTML elements and a single Javascript call to start the whole thing up. I like the Prototype framework, so I decided to use that to power JProQuiz, hence the &#8220;Pro&#8221; part. I also used the Scriptaculous builder so I wouldn&#8217;t have too much messy HTML in the class file. The entire class file (<a title="quiz.js" href="http://su.percilio.us/examples/jproquiz/inc/quiz.js" target="_blank">quiz.js</a>) is less than 300 lines long and the majority of those are comments. (Can you tell I&#8217;m a little proud of it?)</p>
<p>The basic idea is a single class that acts as an engine and using a JSON configuration file, which contains all the quiz questions, options, and correct answers, drives the entire quiz experience for the user. Now, you&#8217;re probably wondering: &#8220;How do you keep the JSON config file obfuscated so that people can&#8217;t just look at the answers?&#8221; Err&#8230; well&#8230; you can&#8217;t. This quiz is entirely browser-side, so the data has to be available to the front end. The JSON file is sort of buried in the class file, so it&#8217;s definitely not immediately obvious where the questions are coming from. It would take someone who knew their way around Javascript to figure out what was going on. And if someone really wants to dig through your code and find your JSON file and read all the answers so they can get a 100% on your little web quiz, well, boogaloo for them. So, don&#8217;t use JProQuiz to power the new on line SATs, just use it for fun little quizzes.</p>
<p>You can <a title="Download JProQuiz" href="http://su.percilio.us/files/jproquiz.zip" target="_self">download JProQuiz here</a>.</p>
<p>And you can <a title="Example of JProQuiz" href="http://su.percilio.us/examples/jproquiz" target="_blank">see a live example here</a>.</p>
<p>If you use JProQuiz please let me know by commenting below. Or if you have any questions, suggestions, or bugs . . . bring &#8216;em on!</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fsu.percilio.us%2F2008%2F08%2Fjproquiz-javascript-quiz-software%2F';
  addthis_title  = 'JProQuiz%3A+Javascript+Quiz+Software';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://su.percilio.us/2008/08/jproquiz-javascript-quiz-software/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Last.FM PHP Image Screen Scraper</title>
		<link>http://su.percilio.us/2008/07/lastfm-php-image-screen-scraper/</link>
		<comments>http://su.percilio.us/2008/07/lastfm-php-image-screen-scraper/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 01:21:24 +0000</pubDate>
		<dc:creator>nick</dc:creator>
				<category><![CDATA[Nerdities]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[last.fm]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://su.percilio.us/?p=32</guid>
		<description><![CDATA[I&#8217;m pretty avid user of Last.FM. I&#8217;m not big on this social networking fad, even if I do work in the industry, but I&#8217;ve found Last.FM very useful, mainly for finding new music. I&#8217;m currently building a web-based media manger in PHP and wanted a way to automatically get images for the artists. I originally [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m pretty avid user of <a title="last.fm" href="http://last.fm" target="_blank">Last.FM</a>. I&#8217;m not big on this social networking fad, even if I do work in the industry, but I&#8217;ve found Last.FM very useful, mainly for finding new music. I&#8217;m currently building a web-based media manger in PHP and wanted a way to automatically get images for the artists.</p>
<p>I originally used the <a title="discogs.com" href="http://discogs.com" target="_blank">discogs.com</a> API and although it was pretty easy to use and reasonably comprehensive, I was really disappointed in the quality of the images, not to mention I was constantly getting back images of electronic and ambient artists who had names similar to the rock bands in my collection, rather than the rock band themselves. I&#8217;m sorry, but when make a call to get images for &#8220;Cream&#8221; I don&#8217;t expect to get back some 14-year-old kid with a turntable and a DAT machine; I want freaking Clapton, Bruce, and Baker.</p>
<p>So, discogs.com left me a bit cold. But I soon learned about Last.FM and was delighted when I discovered their API. The image quality at Last.FM is superb, so I knew I wouldn&#8217;t be disappointed there. I started researching their API and realized that they didn&#8217;t really give me any info I needed other than the images and I didn&#8217;t want to have to sign up for an API key if all I wanted to do was download pictures of bands. Also, they only appear to provide three sizes of images and for many bands they have a whole slew of images available: large, medium, small, smaller, square; I wanted them all, not just the three provided by their API.</p>
<p>So, in the end I decided not to sign up for a Last.FM API key and instead wrote a very simple little PHP screen scraper that would bring back all of the images I wanted. Last.FM actually aided me in my goal by embedding a JSON string with just exactly what I needed right onto the artist page. It worked very well, so I decided to stick with it.</p>
<p>You can <a title="Last.FM PHP Image Screen Scraper" href="http://su.percilio.us/files/lastfm.zip" target="_self">download my simple screen scraper script here</a>. The zip file includes the class file and an example file.</p>
<p>It&#8217; an incredibly simple script. Just a basic class file with only one useable method. It&#8217;s written so it can be expanded, but as Last.FM&#8217;s API is under constant development, it probably won&#8217;t be. But if you just want a simple script to grab artist images from Last.FM, please download my script and let me know if you like it.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fsu.percilio.us%2F2008%2F07%2Flastfm-php-image-screen-scraper%2F';
  addthis_title  = 'Last.FM+PHP+Image+Screen+Scraper';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://su.percilio.us/2008/07/lastfm-php-image-screen-scraper/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
