<?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>When Brains Fly &#187; rest</title>
	<atom:link href="http://www.whenbrainsfly.com/tag/rest/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.whenbrainsfly.com</link>
	<description>An Awesome Blog About Neuroscience, Computer Science, and Technology</description>
	<lastBuildDate>Mon, 28 Jun 2010 01:03:21 +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>REST, AJAX, PHP, la di da</title>
		<link>http://www.whenbrainsfly.com/2010/01/rest-ajax-php-la-di-da/</link>
		<comments>http://www.whenbrainsfly.com/2010/01/rest-ajax-php-la-di-da/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 22:06:08 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[weewar]]></category>

		<guid isPermaLink="false">http://www.whenbrainsfly.com/?p=215</guid>
		<description><![CDATA[Yesterday, I spent much of the day playing around with Javascript and PHP. I had the idea to create a simple web front-end to access the Weewar API and control bots, an alternative to the current main method of controlling bots, which is to use existing non-web-based Java programs to call the API or use [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I spent much of the day playing around with Javascript and PHP. I had the idea to create a simple web front-end to access the <a href="http://weewar.com">Weewar</a> API and control bots, an alternative to the current main method of controlling bots, which is to use existing non-web-based Java programs to call the API or use <a href="http://en.wikipedia.org/wiki/CURL">cURL</a> on the command line. Neither is particularly easy for novice bot developers or those new to programming. Then again, controlling a bot move-by-move manually through a GUI and without programming isn&#8217;t all that practical&#8230; Oh well, it would still be useful for me when I have to do a few simple moves with a bot or two but don&#8217;t want to sign in as the bot, access the game, and do the moves there. Regardless, it was a new mini-project which I could use to sharpen my knowledge of Javascript and PHP, and it was fun. <img src='http://www.whenbrainsfly.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  (<-- whoa, graphical smiley face!)</p>
<p>First, I needed a way to access and display games that a user is currently playing. This can be done with the API: http://weewar.com/api1/user/[username] and is already partially done with the <a href="http://userscripts.org/scripts/show/24555">Weewar Profiler</a> Greasemonkey script, which I was already somewhat familiar with, having had to edit it every time there was a Weewar UI change that broke it. I adapted that to take in a username from an HTML form and use the Javascript XMLHttpRequst object, but then it didn&#8217;t work. It turns out that, unlike Greasemonkey, using normal Javascript, you can&#8217;t make calls to pages outside of your domain, for security reasons. That makes sense, but was a bummer.</p>
<p>So I had to make the API calls from my webhosting server and decided to learn how to do it using PHP, which I barely knew. (What other easy ways are there?) I used <a href="http://developer.yahoo.com/php/howto-reqRestPhp.html">this</a> as a reference, and just now realized upon exploring the Yahoo Developer Center that my approach was already documented here: <a href="http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html">Fixing AJAX: XMLHttpRequest Considered Harmful</a>. Ha! I guess that doesn&#8217;t leave much to say except that I pretty much did method #1 there. </p>
<p>Also, since I had to make many XMLHttpRequest requests, I had to make an array of those objects to keep them from confusing one another. It took me a while to figure out why that was happening, why I was only getting one or a couple requests returned correctly. So I guess that&#8217;s it. Now I know how to make REST calls using sockets in Java, <a href="http://hc.apache.org/httpcomponents-client/index.html">Apache HttpClient</a> in Java, the <a href="http://blog.springsource.com/2009/03/27/rest-in-spring-3-resttemplate/">Spring 3 REST template</a> in Java, XMLHttpRequest objects in Javascript, GM_xmlhttpRequest in Greasemonkey Javascript, and the cURL extension in PHP. Whoo!</p>
<p>Aside: I just realized that the <a href="https://addons.mozilla.org/en-US/firefox/addon/2691">Poster Firefox add-on</a>, which I had downloaded a couple weeks back, makes REST calls as well, and in a much more general-purpose way. Oh well. I wouldn&#8217;t have learned much had I not done all that I had done yesterday, so it was not all for nothing. =) Here is what resulted from it, by the way: <a href="/weewar/weewarbotcontrol.html">Weewar Bot Control</a></p>
<p>Hm. Am I an aspiring web programmer? It certainly is fun and the Internet is the <i>Wave of the Future/Present</i>. I&#8217;ll have to think on that some more. I&#8217;m still quite attached to neuroscience research. At the very least, web programming is a nice, useful hobby. =)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.whenbrainsfly.com/2010/01/rest-ajax-php-la-di-da/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random HTTP Bug and Solution</title>
		<link>http://www.whenbrainsfly.com/2010/01/random-http-bug-and-solution/</link>
		<comments>http://www.whenbrainsfly.com/2010/01/random-http-bug-and-solution/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 06:53:53 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[citrus framework]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://www.whenbrainsfly.com/?p=212</guid>
		<description><![CDATA[I just spent the last fifteen minutes trying to figure out why my HTTP GET request was hanging on input. I had had this problem a few days ago and solved it somehow, but I completely forgot how. It turns out, I just forgot to put a blank line at the end of my GET [...]]]></description>
			<content:encoded><![CDATA[<p>I just spent the last fifteen minutes trying to figure out why my HTTP GET request was hanging on input. I had had this problem a few days ago and solved it somehow, but I completely forgot how. It turns out, I just forgot to put a blank line at the end of my GET request. Stupid. (At least now I know how to fix the mistake next time, even if I forget, because I&#8217;ve written it down here!!! =D)</p>
<p>Also, in searching for code to deal with chunked responses, I came across <a href="http://hc.apache.org/">Apache HttpComponents</a>. I knew something like this existed by Apache but I didn&#8217;t realize that it took care of so much for you. Now I&#8217;m wondering why the <a href="http://www.citrusframework.org/">Citrus Framework</a> doesn&#8217;t use this to handle HTTP requests. Right now, it uses mostly <a href="http://www.springsource.org/">Spring</a> to handle a fair amount of the configuration and message building, but it doesn&#8217;t yet handle chunked responses, at least not that I&#8217;m aware of. Now, to code it manually or use massive amounts of code already written? That&#8217;s obvious. I should talk with the Citrus developer, get onboard, and see if he has a preference first though, since these changes to the Citrus source would be useful to others too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.whenbrainsfly.com/2010/01/random-http-bug-and-solution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
