teaching machines

Homework 3 – meierdg

November 6, 2011 by . Filed under cs491 mobile, fall 2011, postmortems.

I attempted to modify my fortune cookie for program 2 to go out to a web api to retrieve their fortunes as well.  I did this in part to show that all programs can be improved in one way or another, and mainly because my free time is vastly limited by my two jobs.  In the end, however, it saved me no time and didn’t even provide me with a working program.  I tried using the API set up at https://github.com/FernFerret/Fortune to retrieve fortune in the database set up by Dr. Fisher, however no matter which way I attempted to send in my JSON (the api requires a JSON to be sent in, and returns a JSON) I got an html result boiling down to (what I believe) saying that my JSON was empty.  However through debugging I know that it was filled with the proper requirements, and tried multiple different ways of sending in my JSON.  The plan was just to receive their fortune via JSON after pressing “Get a random fortune!” and adding it to the database used in the application.  The app would then proceed as normal afterwards.

On the plus side, from doing this I realized that it would be much easier to use an API that just allows me to use a modified URL to receive a result to have one way of knowing I “asked” for a result correctly.

The html returned:

<!DOCTYPE html>
<html lang=’en’>
<head>
<meta content=’text/html; charset=ISO-8859-1′ http-equiv=’Content-Type’ />
<title>Fortune</title>
<link href=’/css/style.css’ media=’screen’ rel=’stylesheet’ />
</head>
<body>
Example: {“id”: “1”}
<br />
or: {“random”: “true”}
<br />
Note that if an id is specified it will take priority over the random tag
<br />
You tested a post of the following, but it was invalid:
<br />
<strong>
Raw JSON:
</strong>
<br />

<br />
<strong>
The Verdict:
</strong>
<br />
INVALID JSON STRING GIVEN
<br />
<form action=” method=’post’>
<textarea name=’data’></textarea>
<input type=’submit’ value=’Submit JSON’ />
</form>
</body>
</html>