<?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>Printed Matters &#187; development</title>
	<atom:link href="http://burden.ca/blog/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://burden.ca/blog</link>
	<description>Newspapers, their websites, and their future</description>
	<lastBuildDate>Sun, 02 Oct 2011 21:28:39 +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>URL shorteners with APIs</title>
		<link>http://burden.ca/blog/2009/02/url-shorteners-with-apis/</link>
		<comments>http://burden.ca/blog/2009/02/url-shorteners-with-apis/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 22:58:01 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://burden.ca/blog/?p=174</guid>
		<description><![CDATA[This gathering is mainly for my own purposes. But I thought it might be somewhat useful to some other developer so I&#8217;m posting it.
TinyURL
Format: GET http://tinyurl.com/api-create.php?url=&#60;your url here&#62;
Returns: string
bit.ly (Requires API key)
Format: GET http://api.bit.ly/shorten?version=2.0.1&#38;longUrl=&#60;your url here&#62;&#38;login=&#60;your login here&#62;&#38;apiKey=&#60;your api key here&#62;
Returns: JSON [default] or XML
is.gd
Format: http://is.gd/api.php?longurl=&#60;your url here&#62;
Returns: string
Snipurl [snipr.com, snurl.com] (Requires API key)
Format: POST [...]]]></description>
			<content:encoded><![CDATA[<p>This gathering is mainly for my own purposes. But I thought it might be somewhat useful to some other developer so I&#8217;m posting it.</p>
<p><strong><a href="http://tinyurl.com/">TinyURL</a></strong></p>
<p>Format: GET http://tinyurl.com/api-create.php?url=&lt;your url here&gt;</p>
<p>Returns: string</p>
<p><strong><a href="http://bit.ly">bit.ly</a> (Requires <a title="bit.ly API" href="http://code.google.com/p/bitly-api/wiki/ApiDocumentation" target="_blank">API</a> key)</strong></p>
<p>Format: GET http://api.bit.ly/shorten?version=2.0.1&amp;longUrl=&lt;your url here&gt;&amp;login=&lt;your login here&gt;&amp;apiKey=&lt;your api key here&gt;</p>
<p>Returns: JSON [default] or XML</p>
<p><strong><a href="http://is.gd">is.gd</a></strong></p>
<p>Format: http://is.gd/api.php?longurl=&lt;your url here&gt;</p>
<p>Returns: string</p>
<p><strong><a title="Snipurl" href="http://snipr.com/" target="_blank">Snipurl</a> [snipr.com, snurl.com] (Requires <a title="Snipurl API" href="http://snipr.com/site/help?go=api" target="_blank">API</a> key)</strong></p>
<p>Format: POST request</p>
<p>Returns: XML</p>
<p><strong><a title="tr.im" href="http://tr.im/" target="_blank">tr.im</a> (Requires <a title="tr.im API" href="http://tr.im/api" target="_blank">API</a> key over 48 URLs per day)</strong></p>
<p>Format: POST or GET http://api.tr.im/api/trim_url.&lt;format&gt;?url=&lt;your url here&gt;</p>
<p>Returns: XML or JSON</p>
<p><strong><a title="cli.gs" href="http://cli.gs">cli.gs</a> (<a title="cli.gs API" href="http://blog.cli.gs/api" target="_blank">API</a> not required)</strong></p>
<p>Format: GET http://cli.gs/api/v1/cligs/create?url=&lt;your url here&gt;</p>
<p>Returns: string</p>
<p><strong><a title="Tweetburner" href="http://tweetburner.com/" target="_blank">twurl.nl</a> (<a title="Tweetburner API" href="http://tweetburner.com/api" target="_blank">API</a> not required)</strong></p>
<p>Format: POST request</p>
<p>Returns: string</p>
<p><strong>Shorteners seen on Twitter with no API</strong></p>
<p><a title="shrt.at" href="http://shrt.at" target="_blank">shrt.at</a> (<a href="http://shrt.at/api" target="_blank">API</a> not ready)</p>
<p><a title="BudURL" href="http://budurl.com/" target="_blank">budurl.com</a> (API not ready)</p>
<p><a title="url.ie" href="http://url.ie/" target="_blank">url.ie</a> (no API)</p>
]]></content:encoded>
			<wfw:commentRss>http://burden.ca/blog/2009/02/url-shorteners-with-apis/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Why is Google NOT in the social bookmarking space?</title>
		<link>http://burden.ca/blog/2008/08/why-is-google-not-in-the-social-bookmarking-space/</link>
		<comments>http://burden.ca/blog/2008/08/why-is-google-not-in-the-social-bookmarking-space/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 15:35:22 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://burden.ca/blog/?p=76</guid>
		<description><![CDATA[Via TechCrunch: Here&#8217;s a social bookmarking site that downloads the full text of the pages you bookmark so you can search through that text. Yesterday I did a post about bit.ly and I talked about how these new URL shortening sites that are springing up should get into social bookmarking, because it&#8217;s a natural fit. [...]]]></description>
			<content:encoded><![CDATA[<p>Via <a title="Del.izzy Does What Del.icio.us Wonâ€™t: Search The Full Text Of Your Bookmarks" href="http://www.techcrunch.com/2008/08/18/delizzy-does-what-delicious-wont-search-the-full-text-of-your-bookmarks/" target="_blank">TechCrunch</a>: Here&#8217;s a <a title="del.izzy" href="http://www.delizzy.com/" target="_blank">social bookmarking site</a> that downloads the full text of the pages you bookmark so you can search through that text. Yesterday I did <a title="bit.ly missing the boat? - Printed Matters" href="http://burden.ca/blog/2008/08/17/bitly-missing-the-boat" target="_self">a post about bit.ly</a> and I talked about how these new URL shortening sites that are springing up should get into social bookmarking, because it&#8217;s a natural fit. While you&#8217;re on there getting a shorter URL, it would be a simple matter to also bookmark the page. Now here&#8217;s another parallel: both bit.ly and del.izzy go and grab the page when you shorten its URL or bookmark it, respectively.</p>
<p>Why is Google not in this space? It wouldn&#8217;t have to go grab the page when someone bookmarks a page or shortens an URL &#8211; it has already spidered it, in all likelihood. And the bookmarking aspect would integrate nicely with GMail/Reader and the sharing features there.</p>
<p>Update: <a title="Google Bookmarks" href="http://www.google.com/bookmarks/" target="_blank">Google does do bookmarks</a>. Who knew? Pretty low profile. And no social aspect (they&#8217;re private bookmarks). And of course, no integrated URL shortening service.</p>
]]></content:encoded>
			<wfw:commentRss>http://burden.ca/blog/2008/08/why-is-google-not-in-the-social-bookmarking-space/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bit.ly missing the boat?</title>
		<link>http://burden.ca/blog/2008/08/bitly-missing-the-boat/</link>
		<comments>http://burden.ca/blog/2008/08/bitly-missing-the-boat/#comments</comments>
		<pubDate>Sun, 17 Aug 2008 16:18:50 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[development]]></category>

		<guid isPermaLink="false">http://burden.ca/blog/?p=73</guid>
		<description><![CDATA[Just a quick thought on bit.ly, the new URL shortener that everyone is talking about. Why are they talking about it? Well, it adds features on to URL shortening that you never knew you needed. Like semantic web analysis.
But isn&#8217;t that a job for search engines? Why would you want semantic web analysis just on [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick thought on <a title="bit.ly" href="http://bit.ly/" target="_blank">bit.ly</a>, the new URL shortener that <a title="Bit.ly: Please Use This TinyURL of the Future" href="http://www.readwriteweb.com/archives/bitly_alternative_to_tinyurl.php" target="_blank">everyone is talking about</a>. Why are they talking about it? Well, it adds features on to URL shortening that you never knew you needed. Like semantic web analysis.</p>
<p>But isn&#8217;t that a job for search engines? Why would you want semantic web analysis just on the few URLs that users have shortened?</p>
<p>Here&#8217;s what a URL shortener should really do: become a bookmarking site like delicious. Why? Because if a user is already on your site, entering a URL for shortening, it would be a simple matter to also let him add a few tags and a description and save it as a bookmark. I mean, while he&#8217;s there.</p>
<p>What does this have to do with newspapers? Not much, except that it illustrates an important principle: <a title="Why video sucks for newspapers" href="http://burden.ca/blog/2008/02/18/why-video-sucks" target="_self">leverage what you already do</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://burden.ca/blog/2008/08/bitly-missing-the-boat/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>array_multisort is your friend</title>
		<link>http://burden.ca/blog/2008/03/array_multisort-is-your-friend/</link>
		<comments>http://burden.ca/blog/2008/03/array_multisort-is-your-friend/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 00:23:10 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://burden.ca/blog/?p=36</guid>
		<description><![CDATA[More and more these days I&#8217;ve been using Wordpress as the base for web projects. The code base is fantastic, elegant, and simple, and they care about web standards and proper XHTML output. Plugins and themes are easy to write, and the documentation is excellent.
So, for sites that lend themselves to a certain blogginess &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>More and more these days I&#8217;ve been using Wordpress as the base for web projects. The code base is fantastic, elegant, and simple, and they care about web standards and proper XHTML output. Plugins and themes are easy to write, and the documentation is excellent.</p>
<p>So, for sites that lend themselves to a certain blogginess &#8211; sites that are mainly content, updated regularly, and where the content falls within a few different categories &#8211; it&#8217;s a good fit. You can update a core code base from the maintainers, while your plugins and themes for that site remain in separate folders and that&#8217;s the only stuff you have to maintain.</p>
<p>But, sometimes you need to do non-bloggy stuff. For example, on a site for media lawyers I&#8217;m working on, we want a list of all the member lawyers. These lawyers will be able to log on and post things in a contributor or author role, and so they all have accounts on the site. It seemed natural, then, to expand the information stored for each user and use the accounts to generate the member list.</p>
<p><span id="more-36"></span></p>
<p>The first thing I did was download or create a plugin which allowed me to store more information about each author than I could with the stock registration form. I found <a href="http://www.dealsway.net/2007/11/05/wp-user-manager/">WP User Manager</a>, so instead of writing my own I plugged that in.</p>
<p>Next, I created a page (not a post) called &#8220;Media Lawyers&#8221; and assigned to that a template of my own creation. I called mine &#8220;author-list.php&#8221; and stuck it in the folder for the theme I created especially for the site. This file needs to have these magic lines somewhere near the top:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #666666; font-style: italic;">/*
Template Name: Member List
*/</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>That tells Wordpress that this is a template available for use with pages.</p>
<p>Now in this file you write the code for displaying the member list. Wordpress provides a handy function for this: <a href="http://codex.wordpress.org/Template_Tags/wp_list_authors">wp_list_authors()</a>. But there&#8217;s a rub. No, two rubs. The first is that it won&#8217;t list any authors who have not yet written anything. That would make it useless as a member directory, since not even half of them have written stuff for the site yet. The second problem is that we wanted the lawyers to sort by province. A custom function was required.</p>
<p>WP User Manager stores all extra information about authors in the wp_usermeta table, which consists of four columns: id, user id, meta_key, and meta_ value. That&#8217;s logical, because that way the info gets pulled into the author queries that the Wordpress core does, and also your work won&#8217;t be changed or erased the next time you update Wordpress.</p>
<p>Each user might have any number of entries in that table, like <code>131, 5, compname, My Big Lawyer Firm</code>. So you know right away we&#8217;re going to be in to a loop of database calls and some array manipulation. Messy, but no way around it. So let&#8217;s get started:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM <span style="color: #006699; font-weight: bold;">{$wpdb-&gt;users}</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$res</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</p>
<p>That&#8217;s going to pull all the user data out of the main user table, but there&#8217;s no good way to join to the user meta table and get the associated data for each user. So we just have to do another table query as we loop through that list.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$res</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$users</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$user</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$user</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * 
	FROM <span style="color: #006699; font-weight: bold;">{$wpdb-&gt;usermeta}</span> 
	WHERE <span style="color: #006699; font-weight: bold;">{$wpdb-&gt;usermeta}</span>.user_id = <span style="color: #006699; font-weight: bold;">{$user['ID']}</span>&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$res2</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$datum</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$res2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$users</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$user</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$datum</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'meta_key'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> 
						<span style="color: #339933;">=</span> <span style="color: #000088;">$datum</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'meta_value'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now we have all our user data in one place, one entry per user in our <code>$users</code> array.</p>
<p>But wait, how do we sort it? We want the lawyers to sort first by province, then by last name. <code>array_multisort</code> to the rescue. But first, because we have an array of rows, and <code>array_multisort</code> needs an array of columns, we have to create a couple of arrays for <code>array_multisort</code> to sort against. Here comes another loop:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$users</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$prov</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span>  <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wpum_compprov'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$last_name</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'last_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And now we&#8217;re ready for the magic of multisorting:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">array_multisort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$prov</span><span style="color: #339933;">,</span> SORT_ASC<span style="color: #339933;">,</span> <span style="color: #000088;">$last_name</span><span style="color: #339933;">,</span> SORT_ASC<span style="color: #339933;">,</span> <span style="color: #000088;">$users</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>And bingo, I&#8217;ve got a nice sorted array of users with all their data. Now I can loop through that and display it any way I want.</p>
]]></content:encoded>
			<wfw:commentRss>http://burden.ca/blog/2008/03/array_multisort-is-your-friend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

