<?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>boolean.co.nz &#187; Development</title>
	<atom:link href="http://boolean.co.nz/blog/category/development/feed/" rel="self" type="application/rss+xml" />
	<link>http://boolean.co.nz/blog</link>
	<description>Where there is more to logic than TRUE or FALSE</description>
	<lastBuildDate>Sun, 29 Jan 2012 03:16:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Obtain Facebook likes via PHP SDK</title>
		<link>http://boolean.co.nz/blog/facebook-likes-sdk/713/</link>
		<comments>http://boolean.co.nz/blog/facebook-likes-sdk/713/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 03:11:36 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[FaceBook]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=713</guid>
		<description><![CDATA[In an update to this post here is another way to obtain the number of likes for a Facebook page. I&#8217;ll assume that you&#8217;ve already registered a Facebook application, have downloaded the PHP SDK and have included for use in your code. require(&#8216;facebook.php&#8217;); Setup an array with your Facebook applications credentials $facebook = new Facebook(array( [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p>In an update to this <a href="http://boolean.co.nz/blog/get-facebook-likes-and-shares-via-graph-api/626/" title="post" target="_blank">post</a> here is another way to obtain the number of likes for a Facebook page.</p>
<p>I&#8217;ll assume that you&#8217;ve already registered a Facebook application, have downloaded the PHP SDK and have included for use in your code.</p>
<div class="codesnip-container" >require(&#8216;facebook.php&#8217;);</div>
<p>Setup an array with your Facebook applications credentials</p>
<div class="codesnip-container" >$facebook = new Facebook(array(<br />
&#8216;appId&#8217; => &#8217;000000000&#8242;, // Put appID here<br />
&#8216;secret&#8217; => &#8217;0000c000c000c000c&#8217;, // Put your secret key here<br />
));</div>
<p>Decide which page you wish to obtain the number of likes for</p>
<div class="codesnip-container" >$getRequest = $facebook->api(&#8216;/cocacola&#8217;); // Lets look at the Facebook page for the popular soft drink<br />
echo $getRequests['likes'];</div>
<p>Obviously you can consume, contrast and display this information in more exciting ways than simply echoing it to the screen. Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/facebook-likes-sdk/713/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force trailing slash with .htaccess</title>
		<link>http://boolean.co.nz/blog/force-trailing-slash-with-htaccess/684/</link>
		<comments>http://boolean.co.nz/blog/force-trailing-slash-with-htaccess/684/#comments</comments>
		<pubDate>Sun, 06 Nov 2011 23:22:18 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Hosting]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=684</guid>
		<description><![CDATA[There are a few reasons to force a trailing slash at the end of URLs including SEO A quick snippet for your .htaccess is below: &#60;IfModule mod_rewrite.c&#62; RewriteCond %{REQUEST_URI} /+[^\.]+$ RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L] &#60;/IfModule&#62; And while I&#8217;m here a quick snippet to prevent hotlinking of images. This will redirect all requests to a specified [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2011/09/apache_logo.png" alt="" title="apache_logo" width="365" height="57" class="aligncenter size-full wp-image-635" /></td>
</tr>
</table>
<p>There are a few reasons to force a trailing slash at the end of URLs including SEO</p>
<p>A quick snippet for your .htaccess is below:</p>
<div class="codesnip-container" >&lt;IfModule mod_rewrite.c&gt;<br />
 RewriteCond %{REQUEST_URI} /+[^\.]+$<br />
 RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]<br />
&lt;/IfModule&gt;</div>
<p>And while I&#8217;m here a quick snippet to prevent hotlinking of images. This will redirect all requests to a specified image, simply replace yoursite.com with your own URL, and nohotlinking.jpg with your own image and path.</p>
<div class="codesnip-container" >RewriteEngine On<br />
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?yoursite\.com/ [NC]<br />
RewriteCond %{HTTP_REFERER} !^$<br />
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlinking.jpg [L]</div>
<p>And finally a snippet to put in your image assets folder (you have images stored separately right?) to prevent malicious code execution and prevent directory listing of all your assets.</p>
<div class="codesnip-container" >Options All -Indexes<br />
AddHandler cgi-script .php .php4 .php5 .pl .jsp .asp .sh .cgi<br />
Options -ExecCGI</div>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/force-trailing-slash-with-htaccess/684/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox cross domain font embedding</title>
		<link>http://boolean.co.nz/blog/firefox-cross-domain-font-embedding/676/</link>
		<comments>http://boolean.co.nz/blog/firefox-cross-domain-font-embedding/676/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 23:24:59 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Hosting]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=676</guid>
		<description><![CDATA[Firefox has a limitation for cross domain font embedding in that it does not allow you to embed from another website. This .htaccess snippet allows you to bypass this limitation and embed fonts located on another webserver. &#60;FilesMatch &#8220;\.(ttf&#124;otf&#124;eot&#124;woff)$&#8221;&#62; &#60;IfModule mod_headers.c&#62; Header set Access-Control-Allow-Origin &#8220;http://thedomain.com&#8221; &#60;/IfModule&#62; &#60;/FilesMatch&#62;]]></description>
			<content:encoded><![CDATA[<p>Firefox has a limitation for cross domain font embedding in that it does not allow you to embed from another website. This .htaccess snippet allows you to bypass this limitation and embed fonts located on another webserver.</p>
<div class="codesnip-container" >&lt;FilesMatch &#8220;\.(ttf|otf|eot|woff)$&#8221;&gt;<br />
&lt;IfModule mod_headers.c&gt;<br />
    Header set Access-Control-Allow-Origin &#8220;http://thedomain.com&#8221;<br />
&lt;/IfModule&gt;<br />
&lt;/FilesMatch&gt;</div>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/firefox-cross-domain-font-embedding/676/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use PHP to display Gravatar images</title>
		<link>http://boolean.co.nz/blog/use-php-to-display-gravatar-images/668/</link>
		<comments>http://boolean.co.nz/blog/use-php-to-display-gravatar-images/668/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 03:34:25 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=668</guid>
		<description><![CDATA[All URLs on Gravatar are based on the use of the hashed value of an email address. According to their best practice you should: Trim leading and trailing whitespace from an email address Force all characters to lower-case md5 hash the final string Of course in PHP this is trivial as the following function shows: [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p>All URLs on <a href="http://en.gravatar.com/site/implement/hash/" target="_blank">Gravatar</a> are based on the use of the hashed value of an email address. According to their best practice you should:</p>
<ol>
<li>Trim leading and trailing whitespace from an email address</li>
<li>Force all characters to lower-case</li>
<li>md5 hash the final string</li>
</ol>
<p>Of course in PHP this is trivial as the following function shows:</p>
<div class="codesnip-container" >function fetchGravatar() {<br />
$fetchHash = md5(strtolower(trim(&#8216;your_email.address.com&#8217;)));<br />
$GravatarImage = &#8216;http://www.gravatar.com/avatar/&#8217; . $fetchHash;<br />
return $GravatarImage;<br />
}</div>
<p><a href="http://en.gravatar.com/site/implement/profiles/" target="_blank">Profiles</a> are also available if you require them.</p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/use-php-to-display-gravatar-images/668/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSV to .plist conversion</title>
		<link>http://boolean.co.nz/blog/csv-to-plist-conversion/665/</link>
		<comments>http://boolean.co.nz/blog/csv-to-plist-conversion/665/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 08:26:12 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[OSX]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=665</guid>
		<description><![CDATA[Property list files (.pfiles) store serialized objects and are often used to store a user&#8217;s settings. They are also used to store information about bundles and applications in OSX and recently iOS. Danilo Campos wrote some time ago some background information and provided his source and blogged about the subject. Better than that however, he [...]]]></description>
			<content:encoded><![CDATA[<p>Property list files (.pfiles) store serialized objects and are often used to store a user&#8217;s settings. They are also used to store information about bundles and applications in OSX and recently iOS.</p>
<p><a href="http://blog.danilocampos.com/" title="Danilo Campos" target="_blank">Danilo Campos</a> wrote some time ago some background information and provided his <a href="http://code.google.com/p/danilobits/source/checkout" title="source" target="_blank">source</a> and <a href="http://blog.danilocampos.com/2009/12/04/convert-a-csv-into-a-plist-file/" title="blogged" target="_blank">blogged</a> about the subject. Better than that however, he provided an OSX binary to <a href="http://danilobits.googlecode.com/files/Plist%20Converter1.0.zip" title="download" target="_blank">download</a> if you want to get going straight away.</p>
<p>This little application makes it easy to format and process your source data in a familiar environment like Excel and then convert ready to use in your application.</p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/csv-to-plist-conversion/665/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Host Settings Without phpinfo()</title>
		<link>http://boolean.co.nz/blog/php-host-settings-without-phpinfo/652/</link>
		<comments>http://boolean.co.nz/blog/php-host-settings-without-phpinfo/652/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 09:36:05 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=652</guid>
		<description><![CDATA[Occasionally a webhost will block the very useful phpinfo() command making it difficult to understand any limitations of the server configuration. This script can display relevant information to help you understand what is happening behind the scenes. &#60;?php $d_func = ini_get(&#8220;disable_functions&#8221;); $up_max = ini_get(&#8220;upload_max_filesize&#8221;); $up_max = str_replace(&#8220;M&#8221;,&#8221;",$up_max); $up_max_size = &#8220;Megabytes&#8221;; $post_max = ini_get(&#8220;post_max_size&#8221;); $post_max = [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" />
<td>
<tr></table>
<p>Occasionally a webhost will block the very useful phpinfo() command making it difficult to understand any limitations of the server configuration. This script can display relevant information to help you understand what is happening behind the scenes.</p>
<div class="codesnip-container" >&lt;?php<br />
        $d_func = ini_get(&#8220;disable_functions&#8221;);<br />
        $up_max =  ini_get(&#8220;upload_max_filesize&#8221;);<br />
        $up_max = str_replace(&#8220;M&#8221;,&#8221;",$up_max);<br />
        $up_max_size = &#8220;Megabytes&#8221;;<br />
        $post_max = ini_get(&#8220;post_max_size&#8221;);<br />
        $post_max = str_replace(&#8220;M&#8221;,&#8221;",$post_max);<br />
        $post_max_size = &#8220;Megabytes&#8221;;<br />
        $input_max = ini_get(&#8220;max_input_time&#8221;);<br />
        $mem_limit = ini_get(&#8220;memory_limit&#8221;);<br />
        $mem_limit = str_replace(&#8220;M&#8221;,&#8221;",$mem_limit);<br />
        $mem_limit_size = &#8220;Megabytes&#8221;;<br />
        $exec_time = ini_get(&#8220;max_execution_time&#8221;);<br />
        $safe_mode = ini_get(&#8220;safe_mode&#8221;);</p>
<p>        if(!is_null($d_func) &#038;&#038; $d_func !== &#8220;&#8221;){echo  &#8220;Disabled Functions: \n $d_func&#8221;;}<br />
        if(!is_null($safe_mode) &#038;&#038; $safe_mode !== &#8220;&#8221;){echo  &#8220;&lt;span style=&#8217;color:red;&#8217;&gt;Safe Mode is Active&lt;/span&gt; &lt;br&gt;&#8221;;}<br />
        if($up_max >= 1001){$up_max = $up_max / 1024; $up_max_size = &#8220;Gigabytes&#8221;;<br />
        if($up_max >= 10001){$up_max = $up_max / 1024; $up_max_size = &#8220;Terabytes&#8221;;}}<br />
        if($post_max >= 1001){$post_max = $post_max / 1024; $post_max_size = &#8220;Gigabytes&#8221;;<br />
        if($post_max >= 10001){$post_max = $post_max / 1024;$post_max_size = &#8220;Terabytes&#8221;;}}<br />
        if (min($input_max,60)){$input_max = $input_max /60;}<br />
        if (min($exec_time,60)){$exec_time = $exec_time /60;}<br />
        if($mem_limit >= 1001){$mem_limit = $mem_limit / 1024; $mem_limit_size = &#8220;Gigabytes&#8221;;}</p>
<p>        echo &#8220;Maximum Upload Size = $up_max $up_max_size&lt;br&gt;&#8221;;<br />
        echo &#8220;Maximum Post Size = $post_max $post_max_size &lt;br&gt;&#8221;;<br />
        echo &#8220;Maximum Input Time = $input_max minute/s&lt;br&gt;&#8221;;<br />
        echo &#8220;Memory Limit = $mem_limit $mem_limit_size&lt;br&gt;&#8221;;<br />
        echo &#8220;Maximum Execution Time = $exec_time minute/s&lt;br&gt;&#8221;;<br />
?&gt;</p></div>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/php-host-settings-without-phpinfo/652/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Modulo Operator For Alternating Rows</title>
		<link>http://boolean.co.nz/blog/modulo-alternating-rows/647/</link>
		<comments>http://boolean.co.nz/blog/modulo-alternating-rows/647/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 22:24:50 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=647</guid>
		<description><![CDATA[Alternating row colours within a grid of data can make for a more pleasant viewing experience and has become a popular styling method in recent times. I was a little incredulous at some code I saw recently to determine alternating rows so without further introduction, meet the Modulo operator which is a quick and easy [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td>
<img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p>Alternating row colours within a grid of data can make for a more pleasant viewing experience and has become a popular styling method in recent times. I was a little incredulous at some code I saw recently to determine alternating rows so without further introduction, meet the Modulo operator which is a quick and easy way to get up and running:</p>
<div class="codesnip-container" >for($i=0;$i<10;$i++){<br />
  if($i % 2){<br />
   // This is an even row<br />
  }else{<br />
   // This is an odd row<br />
  }<br />
}</div>
<p>I&#8217;m sure you will be able to apply this to your own css or styling within your loops.</p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/modulo-alternating-rows/647/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use cURL to obtain remote filesize</title>
		<link>http://boolean.co.nz/blog/curl-remote-filesize/638/</link>
		<comments>http://boolean.co.nz/blog/curl-remote-filesize/638/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 11:00:46 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=638</guid>
		<description><![CDATA[Sometimes you might want to determine a remote file size prior to determining further action to take. This is a quick function that utilises cURL to retrieve the file size in bytes. &#60;?php function remoteFilesize ($URL){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $URL); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $info = curl_exec($ch); curl_close($ch); [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p>Sometimes you might want to determine a remote file size prior to determining further action to take. This is a quick function that utilises cURL to retrieve the file size in bytes.</p>
<div class="codesnip-container" >&lt;?php<br />
function remoteFilesize ($URL){<br />
	$ch = curl_init();<br />
	curl_setopt($ch, CURLOPT_URL, $URL);<br />
	curl_setopt($ch, CURLOPT_HEADER, true);<br />
	curl_setopt($ch, CURLOPT_NOBODY, true);<br />
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);<br />
	$info = curl_exec($ch);<br />
	curl_close($ch);<br />
	$info = explode(&#8216;Content-Length:&#8217;, $info);<br />
	$info = explode(&#8220;Connection&#8221;,$info[1]);<br />
	return $info[0];<br />
}<br />
?&gt;</div>
<p>Usage is simple:</p>
<div class="codesnip-container" >echo remoteFilesize(&#8220;test.com/file.html&#8221;);</div>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/curl-remote-filesize/638/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Facebook Likes and Shares via Graph API</title>
		<link>http://boolean.co.nz/blog/get-facebook-likes-and-shares-via-graph-api/626/</link>
		<comments>http://boolean.co.nz/blog/get-facebook-likes-and-shares-via-graph-api/626/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 01:46:44 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[FaceBook]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=626</guid>
		<description><![CDATA[Facebook Like and Share count can easily be obtained from the Facebook Graph API. This is an extremely quick way to look up the JSON response from Facebook so that you can further process it for your own requirements. &#60;?php $URL =&#8217;https://graph.facebook.com/cocacola&#8217;; $JSON = file_get_contents($URL); $Output = json_decode($JSON); $Likes = 0; if($Output->likes){ &#160;&#160;$Likes = $Output->likes; [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" />
<td></tr>
</table>
<p>Facebook Like and Share count can easily be obtained from the Facebook Graph API. This is an extremely quick way to look up the JSON response from Facebook so that you can further process it for your own requirements.</p>
<div class="codesnip-container" >&lt;?php<br />
$URL =&#8217;https://graph.facebook.com/cocacola&#8217;;<br />
$JSON = file_get_contents($URL);<br />
$Output = json_decode($JSON);<br />
$Likes = 0;<br />
if($Output->likes){<br />
&nbsp;&nbsp;$Likes = $Output->likes;<br />
}</p>
<p>echo &#8220;Number of likes for CocaCola&#8217;s Facebook Page = &#8220;.$Likes.&#8221;&lt;/br&gt;&#8221;;</p>
<p>$URL2 =&#8217;https://graph.facebook.com/http://www.coca-cola.com&#8217;;<br />
$JSON2 = file_get_contents($URL2);<br />
$Output2 = json_decode($JSON2);<br />
$Shares = 0;<br />
if($Output2->shares){<br />
&nbsp;&nbsp;$Shares = $Output2->shares;<br />
}</p>
<p>echo &#8220;Number of shares for coca-cola.com = &#8220;.$Shares;<br />
?&gt;</p></div>
<p><strong>UPDATE 29/01/2012:</strong> I&#8217;ve written a slightly different method using the PHP SDK in this post <a href="http://boolean.co.nz/blog/facebook-likes-sdk/713" title="here" target="_blank">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/get-facebook-likes-and-shares-via-graph-api/626/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Currency Conversion using Yahoo Finance API</title>
		<link>http://boolean.co.nz/blog/currency-conversion-using-yahoo-finance-api/622/</link>
		<comments>http://boolean.co.nz/blog/currency-conversion-using-yahoo-finance-api/622/#comments</comments>
		<pubDate>Sat, 10 Sep 2011 00:54:08 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=622</guid>
		<description><![CDATA[Just a quick and dirty PHP function to retrieve information from the Yahoo Finance API to perform a currency conversion function ConvertCurrency($From,$To,$Amount){ $URL = &#8216;http://finance.yahoo.com/d/quotes.csv?e=.csv&#038;f=sl1d1t1&#038;s=&#8217;. $From . $To .&#8217;=X&#8217;; $Handle = @fopen($URL, &#8216;r&#8217;); if ($Handle) { $Result = fgets($Handle, 4096); fclose($Handle); } $allData = explode(&#8216;,&#8217;,$Result); $Value = $allData[1]; return $Value * $Amount; } Usage: $Amount [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p>Just a quick and dirty PHP function to retrieve information from the Yahoo Finance API to perform a currency conversion</p>
<div class="codesnip-container" >function ConvertCurrency($From,$To,$Amount){<br />
	$URL = &#8216;http://finance.yahoo.com/d/quotes.csv?e=.csv&#038;f=sl1d1t1&#038;s=&#8217;. $From . $To .&#8217;=X&#8217;;<br />
	$Handle = @fopen($URL, &#8216;r&#8217;);</p>
<p>	if ($Handle) {<br />
    	$Result = fgets($Handle, 4096);<br />
    	fclose($Handle);<br />
	}<br />
	$allData = explode(&#8216;,&#8217;,$Result);<br />
	$Value = $allData[1];</p>
<p>	return $Value * $Amount;<br />
}</p></div>
<p>Usage:</p>
<div class="codesnip-container" >$Amount = ConvertCurrency(&#8220;NZD&#8221;,&#8221;USD&#8221;,25);</div>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/currency-conversion-using-yahoo-finance-api/622/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

