<?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>Application Developer &#187; http</title>
	<atom:link href="http://applicationdeveloper.net/tag/http/feed/" rel="self" type="application/rss+xml" />
	<link>http://applicationdeveloper.net</link>
	<description>Making money online</description>
	<lastBuildDate>Sat, 26 Sep 2009 20:31:22 +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>User Authentication Through Twitter OAuth or cURL</title>
		<link></link>
		<comments>http://applicationdeveloper.net/2009/07/17/user-authentication-twitter-oauth-curl/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 12:43:51 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[Marketing]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[get]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[user management]]></category>

		<guid isPermaLink="false">http://applicationdeveloper.net/?p=68</guid>
		<description><![CDATA[Twitter offers 2 types of authentication. Using the standard cURL GET HTTP protocols or the new and fancy OAuth. cURL is easy, we all get it, and it works great. However, OAuth offers a wide range of fancy features, most importantly, securtiy.Taken from the OAuth website &#8211; An open protocol to allow secure API authorization [...]]]></description>
			<content:encoded><![CDATA[<a href="http://twitter.com/" target="_blank">Twitter</a> offers 2 types of authentication. Using the standard cURL GET HTTP protocols or the new and fancy OAuth. cURL is easy, we all get it, and it works great. However, OAuth offers a wide range of fancy features, most importantly, securtiy.<br /><br />Taken from the <a href="http://oauth.net/" target="_blank">OAuth</a> website &#8211; <em>An <a href="http://oauth.net" target="_blank"><img class="aligncenter size-full wp-image-69" style="float:right;" title="oauth" src="http://applicationdeveloper.net/wp-content/uploads/2009/07/oauth.jpg" alt="oauth" width="215" height="66" /></a>open protocol to allow secure API authorization  in a simple and standard method from desktop and web applications.</em> It&#8217;s a terrific idea and I&#8217;m glad someone is coming out with it. To make things easier there are also developers who&#8217;ve already done the work for you. Here&#8217;s a <a href="http://github.com/abraham/twitteroauth/tree/master" target="_blank">pre-built script</a> that does all the OAuth for you. There&#8217;s also a <a href="http://www.hueniverse.com/hueniverse/2007/10/beginners-guide.html" target="_blank">Beginners Guide</a>.<br /><br />When the benefits are increased security, a higher level of compatibility, and new fancy technology, why bother with cURL anymore?<br /><br />It&#8217;s pretty simple. cURL is easier, and it doesn&#8217;t require anything beyond what we know. Setting everything up with OAuth takes a few hours to wrap your head around. Compared to figuring out OAuth, here&#8217;s how to connect with cURL.<br /><br /><pre class="devcodeblock" title="PHP"><table class="devcodetools"><tbody><tr><td>&nbsp;PHP&nbsp;|&nbsp;</td><td style="background-image:url('http://applicationdeveloper.net/wp-content/plugins/devformatter/img/devformatter-copy.png');background-repeat:no-repeat;background-position:50% 50%;width:16px;height:16px;"/><embed id="ZeroClipboard3" src="http://applicationdeveloper.net/wp-content/plugins/devformatter/_zclipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16px" height="16px" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=3&width=16&height=16" wmode="transparent" /></td><td>&nbsp;copy&nbsp;code&nbsp;|</td><td style="cursor:pointer" title="DevFormatter Plugin" onclick="devfmt_credits()">?</td><td width="99%">&nbsp;</td></tr></tbody></table><div class="devcodeoverflow"><table class="devcodearea" width="100%"><tr><td class="devcodelines" width="1%">01</td><td class="devcodelinesarea"><pre class="devcode devcodeline"></pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">02</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">$loginUsername = &quot;username&quot;;   </pre></td></tr><tr><td class="devcodelines" width="1%">03</td><td class="devcodelinesarea"><pre class="devcode devcodeline">$loginPassword = &quot;password&quot;;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">04</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">&nbsp;</pre></td></tr><tr><td class="devcodelines" width="1%">05</td><td class="devcodelinesarea"><pre class="devcode devcodeline">$url = &quot;https://twitter.com/statuses/followers/&quot; . $username . &quot;.xml&quot;;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">06</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">&nbsp;</pre></td></tr><tr><td class="devcodelines" width="1%">07</td><td class="devcodelinesarea"><pre class="devcode devcodeline">$curl_handle = curl_init();</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">08</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">curl_setopt($curl_handle, CURLOPT_URL, $url);</pre></td></tr><tr><td class="devcodelines" width="1%">09</td><td class="devcodelinesarea"><pre class="devcode devcodeline">curl_setopt($curl_handle, CURLOPT_HTTPGET, 1); //GET method</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">10</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">curl_setopt($curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); //basic authentication</pre></td></tr><tr><td class="devcodelines" width="1%">11</td><td class="devcodelinesarea"><pre class="devcode devcodeline">curl_setopt($curl_handle, CURLOPT_USERPWD, $loginUsername . &quot;:&quot; . $loginPassword); //login</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">12</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);</pre></td></tr><tr><td class="devcodelines" width="1%">13</td><td class="devcodelinesarea"><pre class="devcode devcodeline">curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); //Return the string</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">14</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">$buffer = curl_exec($curl_handle);</pre></td></tr><tr><td class="devcodelines" width="1%">15</td><td class="devcodelinesarea"><pre class="devcode devcodeline">curl_close($curl_handle);</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">16</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"></pre></td></tr></table></div></pre>
<br />There you have it, you're logged in, or at the very least authenticated. Here's how to report back:<br /><br /><pre class="devcodeblock" title="PHP"><table class="devcodetools"><tbody><tr><td>&nbsp;PHP&nbsp;|&nbsp;</td><td style="background-image:url('http://applicationdeveloper.net/wp-content/plugins/devformatter/img/devformatter-copy.png');background-repeat:no-repeat;background-position:50% 50%;width:16px;height:16px;"/><embed id="ZeroClipboard4" src="http://applicationdeveloper.net/wp-content/plugins/devformatter/_zclipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="16px" height="16px" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=4&width=16&height=16" wmode="transparent" /></td><td>&nbsp;copy&nbsp;code&nbsp;|</td><td style="cursor:pointer" title="DevFormatter Plugin" onclick="devfmt_credits()">?</td><td width="99%">&nbsp;</td></tr></tbody></table><div class="devcodeoverflow"><table class="devcodearea" width="100%"><tr><td class="devcodelines" width="1%">1</td><td class="devcodelinesarea"><pre class="devcode devcodeline"></pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">2</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">// check for success or failure</pre></td></tr><tr><td class="devcodelines" width="1%">3</td><td class="devcodelinesarea"><pre class="devcode devcodeline">if (empty($buffer) || strpos($buffer, &quot;Could not authenticate you&quot;)) {</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">4</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"> $replyStatus = &quot;Failed: Please check your username and password&quot;;</pre></td></tr><tr><td class="devcodelines" width="1%">5</td><td class="devcodelinesarea"><pre class="devcode devcodeline">} else {</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">6</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"> $replyStatus = &quot;Success: You are logged in.&quot;;</pre></td></tr><tr><td class="devcodelines" width="1%">7</td><td class="devcodelinesarea"><pre class="devcode devcodeline">}</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">8</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"></pre></td></tr></table></div></pre>
<br /><a href="http://twitter.com/appdevnet" target="_blank"><img style="float:right;" class="alignnone size-full wp-image-70" title="twit-fol" src="http://applicationdeveloper.net/wp-content/uploads/2009/07/twit-fol.jpg" alt="twit-fol" width="200" height="121" /></a>Twitter currently supports both without offering many benefits to either choice. cURL isn't really anything new but it's simple while OAuth will continue to develop. For serious developers who plan for longevity with their Twitter Application sites, I highly recommend taking the extra effort to at least understand OAuth enough to switch to it when they demand it. In the meantime, forget it and stick with cURL until the benefits outweigh the cons.]]></content:encoded>
			<wfw:commentRss>http://applicationdeveloper.net/2009/07/17/user-authentication-twitter-oauth-curl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->