<?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>The Why and The How &#187; Development</title> <atom:link href="http://www.thewhyandthehow.com/category/development/feed/" rel="self" type="application/rss+xml" /><link>http://www.thewhyandthehow.com</link> <description>Just another WordPress weblog</description> <lastBuildDate>Fri, 09 Jul 2010 02:32:51 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.8.4</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>iPhone Development: Native vs. PhoneGap vs. Titanium</title><link>http://www.thewhyandthehow.com/iphone-development-native-vs-phonegap-vs-titanium/</link> <comments>http://www.thewhyandthehow.com/iphone-development-native-vs-phonegap-vs-titanium/#comments</comments> <pubDate>Fri, 09 Jul 2010 02:32:51 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[iPhone]]></category><guid
isPermaLink="false">http://www.thewhyandthehow.com/?p=784</guid> <description><![CDATA[After my last post, I had planned to write a series of how-to&#8217;s related to Titanium mobile app development. Alas, I&#8217;ve changed development modes again.
A brief history of my iPhone app development
I&#8217;m the first to admit that I was very late to the iPhone dev party. I bought a book at least a year ago [...]]]></description> <content:encoded><![CDATA[<p><a
href="http://www.thewhyandthehow.com/wp-content/uploads/2010/07/phones.jpg"><img
src="http://www.thewhyandthehow.com/wp-content/uploads/2010/07/phones-300x217.jpg" alt="Smart Phones" title="Smart Phones" width="300" height="217" class="right size-medium wp-image-789" /></a>After my <a
href="http://www.thewhyandthehow.com/list-based-iphone-navigation-using-titanium/">last post</a>, I had planned to write a series of how-to&#8217;s related to <a
href="http://www.appcelerator.com/">Titanium</a> mobile app development. Alas, I&#8217;ve changed development modes again.</p><h3>A brief history of my iPhone app development</h3><p>I&#8217;m the first to admit that I was very late to the iPhone dev party. I <a
href="http://www.amazon.com/gp/product/1430224592?ie=UTF8&#038;tag=page04-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=1430224592">bought a book</a> at least a year ago and cracked it open. Then I realized it wasn&#8217;t going to be as easy as playing <a
href="http://www.amazon.com/gp/product/B002BUIDO2?ie=UTF8&#038;tag=page04-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=B002BUIDO2">Lego Indiana Jones</a>, so I took a little break.</p><p>When I got back to development, I decided to try out a couple of frameworks that I had been reading about online. The first was <a
href="http://www.phonegap.com/">PhoneGap</a>. It&#8217;s a cool framework that lets you build iPhone applications using Javascript, HTML and CSS. My first app was just a test &#8212; a few buttons, some pages and some basic animations. I was able to put it together very quickly and the result looked good in the iPhone simulator, but it was much too slow on my actual phone. I don&#8217;t think that&#8217;s necessarily a failure of PhoneGap &#8212; it&#8217;s simply that anything that&#8217;s running in the browser is slower than native code. And that&#8217;s what PhoneGap does. It wraps up your Javascript, HTML and CSS into a basic shell of an app and essentially lets mobile Safari do most of the work. That&#8217;s cool, but it just didn&#8217;t have the right feel, so I moved on.</p><p>The second framework I tried was <a
href="http://www.appcelerator.com/">Titanium</a>. Titanium is similar to PhoneGap in the sense that the code is written in Javascript, HTML and CSS. It differs in how that code is ultimately converted to an iPhone app. In Titanium, the programming model mirrors the native (Objective C) model. The code is written in Javascript, but much of it is converted to Objective C and then compiled by Xcode. Some of the code is still passed on to mobile Safari, depending on how you set up your project and what types of views you use, but with Titanium, it is possible to create an app that uses native UIKit (the native iPhone) controls. So I built the app I described in <a
href="http://www.thewhyandthehow.com/list-based-iphone-navigation-using-titanium/">my previous post</a>. The app worked and it was snappy. All the buttons and animations worked as expected. Everything went well until I upgraded my phone to iOS 4.0 and updated XCode and the iPhone SDK.</p><p>After my upgrades, things just stopped working. Weird things &#8230; like my <em>Edit</em> button just stopped appearing on screen, though it was still appearing in the simulator. I upgraded Titanium and tried again, but had no luck.</p><h3>What I&#8217;ve learned</h3><p>First off, let me say that I think both PhoneGap and Titanium are very cool and that I really think having some options for developing iPhone apps is a worthy goal. I&#8217;ve learned that PhoneGap provides some native control options now. That would take care of my speed issues. Titanium is working for many developers, so clearly the problem is either in my code or my configuration.</p><p>However, what I learned was that the biggest portion of the learning curve for me was not so much the syntax of Objective C, but other things such as the development environment (Xcode and IB), the view and controller model of iPhone apps, and the massive amount of stuff in the iPhone SDK. It&#8217;s all a little overwhelming at first. Ironically, by using PhoneGap or Titanium, I wasn&#8217;t able to get completely away from all of these things.</p><h4>The development environments</h4><p>Titanium provides its own IDE of sorts. It&#8217;s a very simple interface. It definitely wins the overwhelming UI battle. PhoneGap doesn&#8217;t have an IDE. You use Xcode. No gain there. There&#8217;s always a learning curve for new software. Xcode and Interface Builder are no exceptions. Just dig in.</p><h4>Development concepts</h4><p>In my first job, I built TCP/IP applications in C on Sun and Cray machines. The first time I had to grok the fork/exec model and use signals to handle sockets, I thought my brain was going to explode. After that I took a job building a Windows application using Delphi 1. Handling memory paging to deal with the fact that our data was larger than the 16-bit systems would allow was the bane of my existence for a week or two. Next I converted that app to a ASP and COM+ application. That whole project was a constant nightmare of IUnknown that I&#8217;d rather forget. And the list goes on and on. After a while, and with a little perseverance all of those new concepts became old concepts as I understood them.</p><p>It&#8217;s the same with developing iPhone apps. Understanding views, windows, table views, navigation controllers, etc. is just about taking the time to dig in and learn. Ironically, to take advantage of the native controls in Titanium (and probably also in PhoneGap), you&#8217;ll have to learn the same concepts &#8212; just in a different language. In fact, by the time I finished my Titanium-based app, I had enough general concepts in my tool box that switching to native was surprisingly obvious. I just had to learn some new syntax.</p><h4>Massive iPhone SDK</h4><p>When iPhone SDK 4 released, Apple included this gem in the overview page: &#8220;a rich set of over 1500 new APIs&#8221;. Fifteen. Hundred. NEW. APIs. Yep, that means that there are <b>a lot</b> more than 1500 APIs in the SDK in general. Cool? Yes. Overwhelming? Definitely.</p><p>Here&#8217;s the thing, though. Using a framework like PhoneGap or Titanium limits your exposure to all those APIs. Is that good or bad? It&#8217;s good if you only need the APIs that are exposed. It&#8217;s bad if you need even one that&#8217;s not. I didn&#8217;t do a thorough review of which elements of the SDK are available under each framework, but most of the standard stuff is available: camera, gps, vibrate, sound, contacts, etc.</p><p>So the answer on this one is that you don&#8217;t have to learn as much stuff in PhoneGap or Titanium, but if your app needs something that&#8217;s not supported by the framework, you&#8217;re either going to have to build it into the framework (Titanium provides some instructions for this &#8212; not sure if PhoneGap allows it) or you&#8217;re going to switch to native. Either way, you&#8217;re going to have to know the native SDK to get there.</p><h3>Last thoughts</h3><p>Learning Objective C (what of it I know) has been an interesting challenge. I hoped it would be like C or C++. It&#8217;s a little like C. Syntactically it&#8217;s not like C++, but having a handle on OO from C++ has helped. I bought a <a
href="http://www.amazon.com/gp/product/0321566157?ie=UTF8&#038;tag=page04-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=0321566157">good Objective C book</a> to go along with my iPhone book and I&#8217;ve been really happy with both. I&#8217;m reading the Objective C book cover to cover. I&#8217;m a little more than half-way through and really glad I chose to read it. I&#8217;ve read most of the iPhone book, but I use it more as a reference for specific tasks.</p><p>Getting up the learning curve with the native development tools for the iPhone has been extremely rewarding. The apps that generated are quick and small and just <em>feel</em> right. I&#8217;m definitely going to stick with the native development tools. I think the other tools have a place and I applaud those who are developing them for their efforts to simplify iPhone app development. For me, though, the key was simply allowing myself to take the time to really get up to speed rather than trying to shortcut the development process with a third-party tool. Your mileage may vary &#8230; and I&#8217;d love to hear your thoughts.</p> ]]></content:encoded> <wfw:commentRss>http://www.thewhyandthehow.com/iphone-development-native-vs-phonegap-vs-titanium/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Desert Code Camp</title><link>http://www.thewhyandthehow.com/desert-code-camp/</link> <comments>http://www.thewhyandthehow.com/desert-code-camp/#comments</comments> <pubDate>Sat, 07 Nov 2009 05:00:30 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[connect]]></category> <category><![CDATA[facebook]]></category><guid
isPermaLink="false">http://www.thewhyandthehow.com/?p=766</guid> <description><![CDATA[Here, finally is the post for Desert Code Camp that I promised to make available. First off, thanks to everyone who attended my session on Integrating Facebook Connect. Secondly, please feel free to ask me questions via email, Twitter, or by commenting here.
Please feel free to download the source code. For each file in the [...]]]></description> <content:encoded><![CDATA[<p>Here, finally is the post for Desert Code Camp that I promised to make available. First off, thanks to everyone who attended my session on Integrating Facebook Connect. Secondly, please feel free to ask me questions via email, Twitter, or by commenting here.</p><p>Please feel free to <a
class="track-download" title="Facebook Connect Presentation" rel="ZIP" href="/wp-content/uploads/2009/11/fbp.zip">download the source code</a>. For each file in the source archive, there is an initial file and a final file. The final version of each file is the more interesting one with the FB code integrated.</p><p>In the code you&#8217;ll find usage samples for the following:<ul><li>FB.ensureInit</li><li>FB.Connect.requireSession</li><li>FB.Connect.forceSessionRefresh</li><li>FB.Connect.logout</li><li>FB.init</li><li>FB_RequireFeatures</li><li>fb:profile-pic</li><li>fb:name</li><li>FB.Facebook.apiClient.friends_get</li><li>FB.XFBML.Host.parseDomTree</li><li>FB.Facebook.apiClient.users_getInfo</li><li>fb:live-stream</li></ul><p>The demo site is still live at <a
href="http://xfcg.com/fbp/">http://xfcg.com/fbp</a>. For example, the page in the source archive called event-final.html is at <a
href="http://xfcg.com/fbp/event-final.html">http://xfcg.com/fbp/event-final.html</a>.</p><p>Here are the basic steps for setting up a new Facebook Connect application:</p><ol><li>Install the <a
href="http://www.facebook.com/apps/application.php?id=2345053339">Facebook Developer Application</a> on your Facebook profile</li><li>Create a new application</li><li>Upload the xd_receiver file</li><li>Add the FB xmlns attribute to your html tag</li><li>Add the Facebook JS file</li><li>Call init in your page</li></ol><p>More information about Facebook Connect Integration is available from these other posts:<ul><li><a
href="http://www.thewhyandthehow.com/integrating-facebook-connect-using-the-thesis-theme/">Integrating Facebook Connect</a></li><li><a
href="http://www.thewhyandthehow.com/facebook-connect-comments-as-wordpress-plugin/">Facebook Connect comments as WordPress Plugin</a></li><li><a
href="http://www.thewhyandthehow.com/use-twitter-facebook-oauth-or-openid-for-login/">Use Twitter, Facebook, OAuth or OpenID for login?</a></li></ul><p>Again, please comment or message me if I&#8217;ve missed something important or if I didn&#8217;t answer your specific question. I&#8217;d love to be able to help.</p> ]]></content:encoded> <wfw:commentRss>http://www.thewhyandthehow.com/desert-code-camp/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Signing AWS requests in PHP</title><link>http://www.thewhyandthehow.com/signing-aws-requests-in-php/</link> <comments>http://www.thewhyandthehow.com/signing-aws-requests-in-php/#comments</comments> <pubDate>Wed, 19 Aug 2009 22:58:15 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[PHP]]></category><guid
isPermaLink="false">http://www.thewhyandthehow.com/?p=750</guid> <description><![CDATA[Recently Amazon added the requirement that all requests must be signed. The process of signing requests is documented on this product advertising API page. Based on the steps listed there, and with a lot of help from @giltotherescue, I was able to create a PHP function to create a signed request URI based on a [...]]]></description> <content:encoded><![CDATA[<p>Recently Amazon added the requirement that all requests must be signed. The process of signing requests is documented on this <a
href="http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html?rest-signature.html">product advertising API</a> page. Based on the steps listed there, and with a lot of help from <a
href="http://twitter.com/giltotherescue">@giltotherescue</a>, I was able to create a PHP function to create a signed request URI based on a simple set of request parameters.</p><div
id="wp_codebox_msgheader"><span
class="right"><a
href="javascript:;" onclick="toggle_collapse('p7504');">[<span
id="p7504_symbol">-</span>]</a><sup><a
href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span
style="color: #99cc00">?</span></a></sup></span><span
class="left"><a
href="javascript:;" onclick="javascript:showCodeTxt('p750code4'); return false;">View Code</a> PHP</span><div
class="codebox_clear"></div></div><div
id="wp_codebox"><table
width="100%" ><tr
id="p7504"><td
class="code" id="p750code4"><pre class="php"><span style="color: #000000; font-weight: bold;">function</span> makeAWSUrl<span style="color: #009900;">&#40;</span><span style="color: #000033;">$parameters</span><span style="color: #339933;">,</span> <span style="color: #000033;">$associate_tag</span><span style="color: #339933;">,</span> <span style="color: #000033;">$access_key</span><span style="color: #339933;">,</span> <span style="color: #000033;">$secret_key</span><span style="color: #339933;">,</span> <span style="color: #000033;">$aws_version</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'2009-06-01'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000033;">$host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'ecs.amazonaws.com'</span><span style="color: #339933;">;</span>
  <span style="color: #000033;">$path</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/onca/xml'</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000033;">$query</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span>        
    <span style="color: #0000ff;">'Service'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'AWSECommerceService'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'AWSAccessKeyId'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000033;">$access_key</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'AssociateTag'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000033;">$associate_tag</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'Timestamp'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/gmdate"><span style="color: #990000;">gmdate</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d<span style="color: #000099; font-weight: bold;">\T</span>H:i:s<span style="color: #000099; font-weight: bold;">\Z</span>'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'Version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000033;">$aws_version</span><span style="color: #339933;">,</span>
  <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Merge in any options that were passed in</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000033;">$parameters</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000033;">$query</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array_merge"><span style="color: #990000;">array_merge</span></a><span style="color: #009900;">&#40;</span><span style="color: #000033;">$query</span><span style="color: #339933;">,</span> <span style="color: #000033;">$parameters</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Do a case-insensitive, natural order sort on the array keys.</span>
  <a href="http://www.php.net/ksort"><span style="color: #990000;">ksort</span></a><span style="color: #009900;">&#40;</span><span style="color: #000033;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// create the signable string</span>
  <span style="color: #000033;">$temp</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000033;">$query</span> <span style="color: #b1b100;">as</span> <span style="color: #000033;">$k</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000033;">$v</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000033;">$temp</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%7E'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'~'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/rawurlencode"><span style="color: #990000;">rawurlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000033;">$k</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'='</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'%7E'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'~'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/rawurlencode"><span style="color: #990000;">rawurlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000033;">$v</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000033;">$signable</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">,</span> <span style="color: #000033;">$temp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000033;">$stringToSign</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;GET<span style="color: #000099; font-weight: bold;">\n</span>$host<span style="color: #000099; font-weight: bold;">\n</span>$path<span style="color: #000099; font-weight: bold;">\n</span>$signable&quot;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// Hash the AWS secret key and generate a signature for the request.</span>
  <span style="color: #000033;">$hex_str</span> <span style="color: #339933;">=</span> hash_hmac<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sha256'</span><span style="color: #339933;">,</span> <span style="color: #000033;">$stringToSign</span><span style="color: #339933;">,</span> <span style="color: #000033;">$secret_key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000033;">$raw</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000033;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000033;">$i</span> <span style="color: #339933;">&lt;</span> <a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000033;">$hex_str</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000033;">$i</span> <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000033;">$raw</span> <span style="color: #339933;">.=</span> <a href="http://www.php.net/chr"><span style="color: #990000;">chr</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/hexdec"><span style="color: #990000;">hexdec</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000033;">$hex_str</span><span style="color: #339933;">,</span> <span style="color: #000033;">$i</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000033;">$query</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Signature'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/base64_encode"><span style="color: #990000;">base64_encode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000033;">$raw</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <a href="http://www.php.net/ksort"><span style="color: #990000;">ksort</span></a><span style="color: #009900;">&#40;</span><span style="color: #000033;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000033;">$temp</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000033;">$query</span> <span style="color: #b1b100;">as</span> <span style="color: #000033;">$k</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000033;">$v</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000033;">$temp</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/rawurlencode"><span style="color: #990000;">rawurlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000033;">$k</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'='</span> <span style="color: #339933;">.</span> <a href="http://www.php.net/rawurlencode"><span style="color: #990000;">rawurlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000033;">$v</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000033;">$final</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;'</span><span style="color: #339933;">,</span> <span style="color: #000033;">$temp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'http://'</span> <span style="color: #339933;">.</span> <span style="color: #000033;">$host</span> <span style="color: #339933;">.</span> <span style="color: #000033;">$path</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'?'</span> <span style="color: #339933;">.</span> <span style="color: #000033;">$final</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>Using the function is simple. The first parameter is a PHP array of AWS parameters, the others are standard associate tags and keys. Here&#8217;s an example:</p><div
id="wp_codebox_msgheader"><span
class="right"><a
href="javascript:;" onclick="toggle_collapse('p7505');">[<span
id="p7505_symbol">-</span>]</a><sup><a
href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span
style="color: #99cc00">?</span></a></sup></span><span
class="left"><a
href="javascript:;" onclick="javascript:showCodeTxt('p750code5'); return false;">View Code</a> PHP</span><div
class="codebox_clear"></div></div><div
id="wp_codebox"><table
width="100%" ><tr
id="p7505"><td
class="code" id="p750code5"><pre class="php"><span style="color: #000033;">$url</span> <span style="color: #339933;">=</span> makeAWSUrl<span style="color: #009900;">&#40;</span><a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Keywords'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Jaco Pastorius'</span><span style="color: #339933;">,</span>                           
                      <span style="color: #0000ff;">'Operation'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ItemSearch'</span><span style="color: #339933;">,</span>                          
                      <span style="color: #0000ff;">'ResponseGroup'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Medium'</span><span style="color: #339933;">,</span>                           
                      <span style="color: #0000ff;">'SearchIndex'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Music'</span><span style="color: #339933;">,</span>                           
                      <span style="color: #0000ff;">'salesrank'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Bestselling'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>  
  <span style="color: #0000ff;">'YOUR_ASSOC_TAG'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'YOUR_ACCESS_KEY'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'YOUR_SECRET_KEY'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>The result of the above call (using my tags and keys) is:</p><div
id="wp_codebox_msgheader"><span
class="right"><a
href="javascript:;" onclick="toggle_collapse('p7506');">[<span
id="p7506_symbol">-</span>]</a><sup><a
href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span
style="color: #99cc00">?</span></a></sup></span><span
class="left"><a
href="javascript:;" onclick="javascript:showCodeTxt('p750code6'); return false;">View Code</a> PHP</span><div
class="codebox_clear"></div></div><div
id="wp_codebox"><table
width="100%" ><tr
id="p7506"><td
class="code" id="p750code6"><pre class="php">http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//ecs.amazonaws.com/onca/xml?AWSAccessKeyId=[MYKEY]&amp;AssociateTag=blakesblogand-20&amp;Keywords=Jaco%20Pastorius&amp;Operation=ItemSearch&amp;ResponseGroup=Medium&amp;SearchIndex=Music&amp;Service=AWSECommerceService&amp;Signature=qZ%2BheDqfZi79b2Xg0JSP2kgG2FgQn823GLn0m1sVmnM%3D&amp;Timestamp=2009-08-19T22%3A53%3A29Z&amp;Version=2009-06-01&amp;salesrank=Bestselling</span></pre></td></tr></table></div><p>As always, give me some feedback, take the code and make it better. Share it and include it in your libraries &#8230; have fun!</p> ]]></content:encoded> <wfw:commentRss>http://www.thewhyandthehow.com/signing-aws-requests-in-php/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>SCP for Komodo IDE</title><link>http://www.thewhyandthehow.com/scp-for-komodo-ide/</link> <comments>http://www.thewhyandthehow.com/scp-for-komodo-ide/#comments</comments> <pubDate>Tue, 18 Aug 2009 00:15:33 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Technology]]></category><guid
isPermaLink="false">http://www.thewhyandthehow.com/?p=746</guid> <description><![CDATA[I have just finished developing my first Komodo IDE plugin. I love Komodo. It&#8217;s the first IDE for PHP that I&#8217;ve been very, very happy using. I&#8217;ve run it on Windows, Linux and now on a MacBook. The only frustration I&#8217;ve had is that Komodo doesn&#8217;t support basic integrated file uploading via SCP. While it [...]]]></description> <content:encoded><![CDATA[<p>I have just finished developing my first <a
href="http://www.activestate.com/komodo/">Komodo IDE</a> plugin. I love Komodo. It&#8217;s the first IDE for PHP that I&#8217;ve been very, very happy using. I&#8217;ve run it on Windows, Linux and now on a MacBook. The only frustration I&#8217;ve had is that Komodo doesn&#8217;t support basic integrated file uploading via SCP. While it is possible to save a file remotely, there is no simple way to save a file locally and upload it to a mapped location on a remote server from within the IDE.</p><p>Fortunately Komodo also provides a simple method for creating extensions within the IDE itself, so I gave it a try. Within a few hours I was able to build an extension to do exactly what I needed and configure it on a per-project basis. I&#8217;ve made the extension available as an <a
href="http://code.google.com/p/scp-for-komodo-ide/">MIT-licensed, open-source project</a>. As always, this project is included on the <a
href="http://www.thewhyandthehow.com/open-source-tools/">open source tools page</a>.</p> ]]></content:encoded> <wfw:commentRss>http://www.thewhyandthehow.com/scp-for-komodo-ide/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Facebook Connect comments as WordPress plugin</title><link>http://www.thewhyandthehow.com/facebook-connect-comments-as-wordpress-plugin/</link> <comments>http://www.thewhyandthehow.com/facebook-connect-comments-as-wordpress-plugin/#comments</comments> <pubDate>Fri, 14 Aug 2009 15:48:31 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[facebook]]></category> <category><![CDATA[wordpress]]></category><guid
isPermaLink="false">http://www.thewhyandthehow.com/?p=741</guid> <description><![CDATA[My article Integrating Facebook Connect using the Thesis theme has generated a great deal of interest and several requests for a WordPress plugin. I personally haven&#8217;t had the time or inclination to create a plugin, but my friend and colleague Aaron Collegeman has. He was interested in the concept for one of his projects and [...]]]></description> <content:encoded><![CDATA[<p>My article <a
href="http://www.thewhyandthehow.com/integrating-facebook-connect-using-the-thesis-theme/">Integrating Facebook Connect using the Thesis theme</a> has generated a great deal of interest and several requests for a WordPress plugin. I personally haven&#8217;t had the time or inclination to create a plugin, but my friend and colleague <a
href="http://aaroncollegeman.com/">Aaron Collegeman</a> has. He was interested in the concept for one of his projects and asked permission to use my code.</p><p>Yesterday he released the <a
href="http://code.google.com/p/wpfb/">plugin as an open source project</a>. I haven&#8217;t had a chance to install the plugin, but having worked with Aaron in the past, I&#8217;m sure it&#8217;s top notch. I looked at the source code and really like the way he developed the integration with WordPress.</p><p>If you&#8217;re interested in adding Facebook comments to your WordPress blog, I suggest you give Aaron&#8217;s plugin a try. I&#8217;ve included this plugin on my <a
href="http://www.thewhyandthehow.com/open-source-tools/">open source tools page</a>.</p> ]]></content:encoded> <wfw:commentRss>http://www.thewhyandthehow.com/facebook-connect-comments-as-wordpress-plugin/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Doing more at once</title><link>http://www.thewhyandthehow.com/doing-more-at-once/</link> <comments>http://www.thewhyandthehow.com/doing-more-at-once/#comments</comments> <pubDate>Wed, 17 Jun 2009 17:48:26 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[General]]></category> <category><![CDATA[database]]></category> <category><![CDATA[facebook]]></category><guid
isPermaLink="false">http://www.thewhyandthehow.com/?p=736</guid> <description><![CDATA[I&#8217;ve been doing a lot of work with curl_multi in PHP lately because it just makes sense to do as much work in parallel as possible (in most cases). I&#8217;ll be writing up my experiences with curl_multi later.
So, yesterday&#8217;s announcement by the Facebook development team about fql.multiquery couldn&#8217;t have come at a better time for [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;ve been doing a lot of work with <a
href="http://us2.php.net/manual/en/function.curl-multi-exec.php">curl_multi in PHP</a> lately because it just makes sense to do as much work in parallel as possible (in most cases). I&#8217;ll be writing up my experiences with curl_multi later.</p><p>So, yesterday&#8217;s announcement by the Facebook development team about <a
href="http://developers.facebook.com/news.php?blog=1&#038;story=257">fql.multiquery</a> couldn&#8217;t have come at a better time for me. Experienced web developers (and multi-tiered application developers in general) have all learned that performing work in the proper tier is always the most efficient way to work. Data should be managed in the database tier and as separately from the application tier as possible. This announcement from the Facebook development team is great news for Facebook application developers everywhere. Kudos to them!</p> ]]></content:encoded> <wfw:commentRss>http://www.thewhyandthehow.com/doing-more-at-once/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Poor programmer&#8217;s website monitor</title><link>http://www.thewhyandthehow.com/poor-programmers-website-monitor/</link> <comments>http://www.thewhyandthehow.com/poor-programmers-website-monitor/#comments</comments> <pubDate>Tue, 26 May 2009 15:30:19 +0000</pubDate> <dc:creator>Blake Schwendiman</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[Networking]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[Tutorial]]></category><guid
isPermaLink="false">http://www.thewhyandthehow.com/?p=720</guid> <description><![CDATA[If you manage your own web site, it&#8217;s critical to know when there are problems, and hopefully you&#8217;ll know before your users do. There are several enterprise-grade server monitors and website monitors available ranging from free to expensive, but if you need something right now that&#8217;s simple and free, you might consider the solution I [...]]]></description> <content:encoded><![CDATA[<p>If you manage your own web site, it&#8217;s critical to know when there are problems, and hopefully you&#8217;ll know before your users do. There are several enterprise-grade server monitors and website monitors available ranging from free to expensive, but if you need something right now that&#8217;s simple and free, you might consider the solution I put together using <a
href="http://www.montastic.com/">Montastic</a>, <a
href="http://pipes.yahoo.com/pipes/">Yahoo! Pipes</a> and my cell phone.</p><p>My solution is not enterprise and it&#8217;s not real time, but it will let me know in a reasonable amount of time (Montastic says it checks every 10 minutes or so, based on load). For me, that&#8217;s good enough right now because I mostly want to avoid overnight and weekend-long outages that may occur when I&#8217;m not checking my computer regularly.</p><p>The first step is to sign up at <a
href="http://www.montastic.com/signup">Montastic</a> and set up a monitor for your web site. There&#8217;s no learning curve there &#8230; just register, type in a URL and Montastic will start monitoring right away. There&#8217;s a <a
href="http://www.montastic.com/video.html">video screen cast</a> available showing how easy it is to use. After setting up the monitors, Montastic provides a basic RSS feed &#8212; that&#8217;s where <a
href="http://pipes.yahoo.com/pipes/">Yahoo! Pipes</a> comes in.</p><p><div
id="attachment_722" class="wp-caption alignright" style="width: 150px"> <a
href="http://www.thewhyandthehow.com/wp-content/uploads/2009/05/yahoo-pipes-pipe.png"><img
src="http://www.thewhyandthehow.com/wp-content/uploads/2009/05/yahoo-pipes-pipe-150x150.png" alt="Yahoo! Pipes Configuration for Montastic" title="yahoo-pipes-pipe" width="150" height="150" class="size-thumbnail wp-image-722" /></a><p
class="wp-caption-text">Yahoo! Pipes Configuration for Montastic</p></div>If you&#8217;re not familiar with Yahoo! Pipes, you should <a
href="http://www.jumpcut.com/fullscreen?id=F4396574585311DC87A2000423CF0184&#038;type=clip">watch this video</a> for a brief introduction. For my monitor application, I built a very simple pipe that takes the output of the Montastic RSS feed, filters out all items that have the text [OK] in the title and then simply return the remaining titles. The entire pipe layout is in the attached screenshot.</p><p>The final step I took was to simply run the pipe, then tell Yahoo! to send me the output of the pipe to my cell phone whenever it changes. Since the pipe updates when there is a new failure item, I won&#8217;t get an SMS message every time Montastic checks the servers, but only when there is a new failure item.</p><p>I haven&#8217;t been running this solution for very long, but so far it looks to be a promising concept for keeping an eye on my servers &#8212; particularly when I&#8217;m going to be away for a while. I&#8217;d love to hear ideas about other ways to use Montastic or suggestions for other free website monitoring tools. What do you use?</p> ]]></content:encoded> <wfw:commentRss>http://www.thewhyandthehow.com/poor-programmers-website-monitor/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Amazon web services change for associates</title><link>http://www.thewhyandthehow.com/amazon-web-services-change-for-associates/</link> <comments>http://www.thewhyandthehow.com/amazon-web-services-change-for-associates/#comments</comments> <pubDate>Sat, 09 May 2009 00:36:00 +0000</pubDate> <dc:creator>Blake Schwendiman</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[REST]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[aws]]></category> <category><![CDATA[tech]]></category><guid
isPermaLink="false">http://www.thewhyandthehow.com/?p=677</guid> <description><![CDATA[Although I haven&#8217;t written about it yet, for me the most important set of web services and APIs for my work are provided by Amazon. Without a doubt I use these services more than any others. Today I received this message:Effective immediately, we are renaming the Amazon Associates Web Service as the “Product Advertising API.” [...]]]></description> <content:encoded><![CDATA[<p>Although I haven&#8217;t written about it yet, for me the most important set of web services and APIs for my work are provided by Amazon. Without a doubt I use these services more than any others. Today I received this message:</p><div
class="quote"><p>Effective immediately, we are renaming the Amazon Associates Web Service as the “Product Advertising API.” This new name more accurately reflects the purpose of the API, which is to enable developers to advertise products offered on the Amazon sites and thereby receive advertising fees from us.</p><p
class="para-break">In addition to the new name, signatures will be necessary to authenticate each call to the Product Advertising API. This requirement will be phased in starting May 11, 2009, and by August 15, 2009, all calls to the Product Advertising API must be authenticated or they will not be processed.</p></div><p>Because this will have a big impact on any developer, I wanted to share a couple of links I found today. First is the documentation page: <a
href="http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/rest-signature.html">Signing AWS Commerce API requests</a>. The second is a recommendation from <a
href="http://twitter.com/giltotherescue">Gil</a> (the genius that keeps <a
href="http://www.squidoo.com/">Squidoo</a> running): <a
href="http://tarzan-aws.com/">Tarzan: A fast, powerful PHP toolkit for building web applications with Amazon Web Services</a>. This library looks like a great resource for developing against many of the AWS services. I&#8217;ll be doing some investigation and will follow up when I can talk more intelligently about it.</p><p>For now, good luck with your current AWS projects!</p> ]]></content:encoded> <wfw:commentRss>http://www.thewhyandthehow.com/amazon-web-services-change-for-associates/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Building an Ajax content proxy in PHP</title><link>http://www.thewhyandthehow.com/building-an-ajax-content-proxy-in-php/</link> <comments>http://www.thewhyandthehow.com/building-an-ajax-content-proxy-in-php/#comments</comments> <pubDate>Tue, 05 May 2009 17:21:47 +0000</pubDate> <dc:creator>Blake Schwendiman</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[Tutorial]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[Ajax]]></category><guid
isPermaLink="false">http://www.thewhyandthehow.com/?p=644</guid> <description><![CDATA[Last week I wanted to write an article about using Google docs as a data store for use in Javascript, but in order to do so, I first need to provide a basic article about content proxies.
For security reasons, Ajax requests are only allowed to domains from which the code originates. For example, if your [...]]]></description> <content:encoded><![CDATA[<p>Last week I wanted to write an article about using Google docs as a data store for use in Javascript, but in order to do so, I first need to provide a basic article about content proxies.</p><p>For security reasons, Ajax requests are only allowed to domains from which the code originates. For example, if your site is at example.com, and your Javascript is served from that domain, you may only use Ajax to make HTTP requests to the same domain, example.com. If you want to retrieve data from other web services such as <a
href="http://developer.yahoo.com/finance/">financial information</a> or <a
href="http://developer.yahoo.com/finance/">weather</a> from <a
href="http://developer.yahoo.com/">Yahoo!</a>, you cannot make a direct Ajax request to yahoo.com, but you can make a request to a content proxy on example.com that gets the data from Yahoo! and returns it for you.</p><p>A very simple content proxy in PHP is implemented (using curl) like this:</p><div
id="wp_codebox_msgheader"><span
class="right"><a
href="javascript:;" onclick="toggle_collapse('p64410');">[<span
id="p64410_symbol">-</span>]</a><sup><a
href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span
style="color: #99cc00">?</span></a></sup></span><span
class="left"><a
href="javascript:;" onclick="javascript:showCodeTxt('p644code10'); return false;">View Code</a> PHP</span><div
class="codebox_clear"></div></div><div
id="wp_codebox"><table
width="100%" ><tr
id="p64410"><td
class="code" id="p644code10"><pre class="php"><span style="color: #666666; font-style: italic;">/**
* perform a remote connection request and return the results
* 
* @param string uri of remote resource
* @param int timeout in seconds
* @param int connection timeout in seconds
* 
* @return string data returned from uri or null
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> remote_load<span style="color: #009900;">&#40;</span><span style="color: #000033;">$uri</span><span style="color: #339933;">,</span> <span style="color: #000033;">$timeout</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span> <span style="color: #000033;">$connect_timeout</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000033;">$curl_handle</span> <span style="color: #339933;">=</span> curl_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000033;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_USERAGENT<span style="color: #339933;">,</span> <span style="color: #0000ff;">'example.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000033;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_URL<span style="color: #339933;">,</span> <span style="color: #000033;">$uri</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000033;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_RETURNTRANSFER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000033;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_CONNECTTIMEOUT<span style="color: #339933;">,</span> <span style="color: #000033;">$connect_timeout</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000033;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_TIMEOUT<span style="color: #339933;">,</span> <span style="color: #000033;">$timeout</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  curl_setopt<span style="color: #009900;">&#40;</span><span style="color: #000033;">$curl_handle</span><span style="color: #339933;">,</span> CURLOPT_FOLLOWLOCATION<span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000033;">$buffer</span>   <span style="color: #339933;">=</span> curl_exec<span style="color: #009900;">&#40;</span><span style="color: #000033;">$curl_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000033;">$curlinfo</span> <span style="color: #339933;">=</span> curl_getinfo<span style="color: #009900;">&#40;</span><span style="color: #000033;">$curl_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  curl_close<span style="color: #009900;">&#40;</span><span style="color: #000033;">$curl_handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000033;">$curlinfo</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'http_code'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">400</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span><span style="color: #000033;">$curlinfo</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'http_code'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000033;">$buffer</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>The above code would be included in a simple page such as:</p><div
id="wp_codebox_msgheader"><span
class="right"><a
href="javascript:;" onclick="toggle_collapse('p64411');">[<span
id="p64411_symbol">-</span>]</a><sup><a
href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span
style="color: #99cc00">?</span></a></sup></span><span
class="left"><a
href="javascript:;" onclick="javascript:showCodeTxt('p644code11'); return false;">View Code</a> PHP</span><div
class="codebox_clear"></div></div><div
id="wp_codebox"><table
width="100%" ><tr
id="p64411"><td
class="code" id="p644code11"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
  <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_function_above'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// you really should check for and handle errors</span>
  <a href="http://www.php.net/print"><span style="color: #990000;">print</span></a><span style="color: #009900;">&#40;</span>remote_load<span style="color: #009900;">&#40;</span><span style="color: #000033;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'uri'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div><p>If the above page is called proxy.php on your site, then you can now make Ajax requests that look like:</p><div
id="wp_codebox_msgheader"><span
class="right"><a
href="javascript:;" onclick="toggle_collapse('p64412');">[<span
id="p64412_symbol">-</span>]</a><sup><a
href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span
style="color: #99cc00">?</span></a></sup></span><span
class="left"><a
href="javascript:;" onclick="javascript:showCodeTxt('p644code12'); return false;">View Code</a> JAVASCRIPT</span><div
class="codebox_clear"></div></div><div
id="wp_codebox"><table
width="100%" ><tr
id="p64412"><td
class="code" id="p644code12"><pre class="javascript">jQuery.<span style="color: #006600;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http://www.example.com/proxy.php?uri=http://www.google.com/'</span><span style="color: #339933;">,</span>
  <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    do_something_with_result<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div><p>There are several considerations to make when developing a content proxy that haven&#8217;t been shown here. The first two that come to mind are security and caching. Requests to third-party services should be cached locally on your server to ensure that your application doesn&#8217;t make too many requests and potentially become blacklisted by the third-party service. Additionally, if you build a content proxy, you should ensure that only requests from your approved callers are satisfied. You don&#8217;t want other sites making proxy requests through your servers for many reasons.</p><p>The proxy shown above may be used as a starting point for a more secure and robust content proxy, though, and will be the basis for some of my upcoming Ajax articles.</p> ]]></content:encoded> <wfw:commentRss>http://www.thewhyandthehow.com/building-an-ajax-content-proxy-in-php/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Twitter, OAuth vulnerability, and service interconnectedness</title><link>http://www.thewhyandthehow.com/twitter-oauth-vulnerability-and-service-interconnectedness/</link> <comments>http://www.thewhyandthehow.com/twitter-oauth-vulnerability-and-service-interconnectedness/#comments</comments> <pubDate>Thu, 23 Apr 2009 17:41:41 +0000</pubDate> <dc:creator>Blake Schwendiman</dc:creator> <category><![CDATA[Development]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[integration]]></category> <category><![CDATA[oauth]]></category> <category><![CDATA[twitter]]></category><guid
isPermaLink="false">http://www.thewhyandthehow.com/?p=592</guid> <description><![CDATA[It&#8217;s ironic that the day that my post on integrating Twitter OAuth (and other third-party authentication) appeared that a vulnerability in OAuth would be identified.
I didn&#8217;t write about the potential hassle that site owners will endure when third-party services become unavailable due to bugs or other problems, but it&#8217;s a huge consideration for web developers. [...]]]></description> <content:encoded><![CDATA[<p>It&#8217;s ironic that the day that my post on <a
href="http://www.thewhyandthehow.com/use-twitter-facebook-oauth-or-openid-for-login/">integrating Twitter OAuth</a> (and other third-party authentication) appeared that a <a
href="http://oauth.net/advisories/2009-1">vulnerability in OAuth</a> would be identified.</p><p>I didn&#8217;t write about the potential hassle that site owners will endure when third-party services become unavailable due to bugs or other problems, but it&#8217;s a huge consideration for web developers.</p><p>If your site is integrated with any other third-party site for any reason, the performance, stability and reliability of the third-party service is <strong>your problem to manage</strong>. Your site users will not care that your site is down because <a
href="http://oauth.net/advisories/2009-1">OAuth is broken</a> or <a
href="http://news.cnet.com/8301-17939_109-9905105-2.html">AWS has an outage</a> or whatever the case may be. They will only know that your site is broken.</p><h4>Mitigation</h4><p>The problem is that you can&#8217;t build and maintain everything &#8212; and you really can&#8217;t jettison third-party integrations generally. You can, however, mitigate against failures by developing graceful failover options. Build failover solutions based on the importance of the third-party service. If your entire registration and login solution is dependent on OAuth, your best bet is to include some type of &#8220;We&#8217;re sorry, but registration and login are temporarily disabled&#8221; messaging. This isn&#8217;t a perfect solution, but it&#8217;s better than &#8220;Error 8000EAF0: Cannot connect garbage garbage garbage&#8221; or a blank screen.</p><p>In many cases, third-party integrations augment your site, but aren&#8217;t necessarily a requirement for using your site. Make sure in those cases (particularly for things such as widgets, ads, analytics, etc.) that if a component fails your site design and usability don&#8217;t collapse.</p><p>Remember that the web is still very young and that everyone &#8212; the big services included &#8212; are still learning how to make this all work together. The best bet for now is to build your system to be as flexible as possible because the frameworks are still shifting.</p><p><strong>Update</strong>: I wrote this article last night (Wednesday), but I typically publish mid-morning. Since I wrote this article, <a
href="http://tinyurl.com">tinyurl.com</a> has experienced an outage.</p> ]]></content:encoded> <wfw:commentRss>http://www.thewhyandthehow.com/twitter-oauth-vulnerability-and-service-interconnectedness/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss><!--
This site's performance optimized by W3 Total Cache:

W3 Total Cache improves the user experience of your blog by caching
frequent operations, reducing the weight of various files and providing
transparent content delivery network integration.

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached
Page Caching using memcached
Database Caching 10/17 queries in 0.011 seconds using memcached

Served from: a2.c0.354a.static.theplanet.com @ 2010-09-07 02:04:26 -->