<?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>NINNYPANTS &#187; PHP</title>
	<atom:link href="http://ninnypants.com/blog/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://ninnypants.com</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Thu, 02 Feb 2012 01:32:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Using the Tinyurl API</title>
		<link>http://ninnypants.com/blog/2009/05/05/using-the-tinyurl-api/</link>
		<comments>http://ninnypants.com/blog/2009/05/05/using-the-tinyurl-api/#comments</comments>
		<pubDate>Tue, 05 May 2009 06:08:59 +0000</pubDate>
		<dc:creator>ninnypants</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[tinyurl]]></category>

		<guid isPermaLink="false">http://www.ninnypants.com/?p=79</guid>
		<description><![CDATA[Lately I've had a need to use the Tinyurl.com API. The API has been usefull for a couple of things since I started using it.
Shortening URL's

This is obviously the intended purpose of the Tinyurl API. With a very simple function you can shorten urls very easily. This function passes the url to the Tinyurl API which shrinks it and then it is pulled back using file_get_contents()]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve had a need to use the Tinyurl.com API. The API has been useful for a couple of things since I started using it.&nbsp;</p>
<h3>Shortening URL&#8217;s</h3>
<p>This is obviously the intended purpose of the Tinyurl API. With a very simple function you can shorten urls very easily. This function passes the url to the Tinyurl API which shrinks it and then it is pulled back using file_get_contents()</p><pre class="crayon-plain-tag"><code>function shrinkUrl($url){
    $url = file_get_contents('http://tinyurl.com/api-create.php?url='.$url);
    return $url;
}
$tinyurl = shrinkUrl('http://www.ninnypants.com');// equal to http://tinyurl.com/6lbwc4</code></pre>
<h3>Generating a Random Key</h3>
<p>The Tinyurl API can also be used to generate a random key specific to the information you pass in. <span style="text-decoration: line-through;">As long as you don&#8217;t pass in a url Tinyurl will only return the the code at the end of the url (6lbwc4)</span> The service now attaches http://tinyurl.com/ the first part of the url to the code also so the random key function takes a little more code.</p><pre class="crayon-plain-tag"><code>function randomKey($url){
    $key = file_get_contents('http://tinyurl.com/api-create.php?url='.$url);
    $key = str_replace('http://tinyurl.com/', '', $key);
    return $key;
}</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://ninnypants.com/blog/2009/05/05/using-the-tinyurl-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

