RSS

PHP5 + JSON + as3corelib = a beautiful thing

0 Comments | This entry was posted on Feb 11 2009

I’ve decided to play around with an experimental front end for viewing projects in Flash. Since I OOPified (yes, that’s a technical term) the site and modeled the data, all of my objects can be easily serialized into JSON strings and passed back to the front end. Then using the as3corelib’s JSON classes, I can deserialize those objects and blammo. So much easier than having PHP output XML, then parsing that XML in flash, and then creating objects from… yeah, that sucks.

So I’ve got all of my stuff coming back into Flash in a format that’s really easy to consume and use and did it with very little work. I like that.

If I wanted to pass back a project object to the front end. I would make a request that would execute something like the following in PHP:

$prj = Alien109DAO::getProjectByPageRef($_REQUEST['p']);
$key = Alien109DAO::getKeywordsByProjectId($prj['id']);
$results = ProjectFactory::createProject($prj, $key);
print_r(json_encode($results));

First I get the project from the database. Then I get all of the associated keywords for that project. I then pass both of those results as arguments to my ProjectFactory which is a static class whose primary job is to just return a full Project object. Then the object is serialized, and returned in the response.

In Flash, in my event listener, I simply deserialize the JSON string back into an ActionScript object using the as3corelib’s JSON decoder class.

private function dataLoaded(e:DataReadyEvent):void
{
var projectObject:Object = JSON.decode(e.data);
...

w00t!

Wordpress XML Parsing Error

1 Comment | This entry was posted on Feb 11 2009

XML Parsing Error: XML or text declaration not at start of entity

> Warning: MagpieRSS: Failed to parse RSS file. (Reserved XML Name at
> line 3, column 38) in [...]
>
> Warning: Invalid argument supplied for foreach() in [...]

Yesterday it was called to my attention that the RSS parser that was pulling the feed from my blog into my web site was throwing some rather nasty errors. Upon further investigation I discovered that the feed itself was the culprit.

Something was throwing in extra white space before the document declaration in the XML file. Some people have found that old plug-ins or themes can cause this problem. I searched through every PHP file and finally found the issue in my config (wp-conifg.php) file.

I just updated to the latest version of WordPress yesterday and when updating the config with the most recent settings, I accidentally added two empty lines before the opening PHP tag.

Ooops. Thanks to Jared over at ShareBrained Technologies for noticing!

Rewriting the back-end, again…

0 Comments | This entry was posted on Feb 08 2009

I’ve decided to rewrite the back end for alien109.com again, taking advantage of OOP in PHP. Man, such a difference. Everything is so much easier to maintain and follow now. Plus, I’ve implemented more of an MVC pattern. Seemed like overkill for such a small site, but proved to be educational, if nothing else.

Site updates!

0 Comments | This entry was posted on Feb 04 2009

So I’ve finally updated my web site.
www.alien109.com

  • Ported all of the javascript over to jQuery and ditched those ancient JavaScript libraries I’d written years ago
  • Implemented some keyword searching on projects so you can see projects based on languages or technologies.
  • Reworked the backend so that everything was a little more search engine friendly (url rewritting for prettier urls and hidden javascript calls)
  • Added a bunch of new (and old) work into the mix.

Creating a search engine friendly ajax app is a pain in the butt, if it’s an after thought :)

Installing Apache, PHP and MySQL on Vista

0 Comments | This entry was posted on Jul 27 2007

I was expecting the worst, but got everything up and running in about 30 minutes due to some damn easy to follow tutorials. I guess I probably could have figured it out myself, but it’s nice to just get it done.

Installing Apache on Vista
Installing PHP on Vista

Installing MySQL is a no-brainer. Hell, even I could do it.