Eve Online API and PHP

A buddy of mine just recently started playing Eve Online and asked me if I could help him out by creating a small application that could help him keep track of his corporations transactions and members.  He directed me to the Eve Online API Documentation and explained what he wanted to do.

I took one quick look at it, saw that they had a Python sample — reviewed it, even tried it myself in a python shell real quick.  Due to the python sample code, I almost said “Oh hey, a perfect use for Google App Engine.  But then decided not to go that route, as I was hoping to host the application myself and have a bit more control over the data and the amount of data I could work with at a time.  I toyed with the idea of writing it in either .NET or PHP and went with PHP.  I haven’t written anything in PHP for a few weeks, and I’m all over the .NET code at my day job … so, PHP was a ‘lets make things more complicated then they have to be’ decision.

As such, to develop this application, I am creating what I call the ‘EveAPI Class’ for PHP — which is basically just a class that has all the necessary functions and properties to retrieve any and all information accessible through the Eve Online API.

A quick example of usage is this:

[php]$eve = EveAPI::Create($userID, $apiKey, $characterId);
$object = $eve->getCorpWalletData();
echo $object.toHtmlTable();[/php]

Yep, it really is that simple — the ‘toHtmlTable’ is a helper function that belongs to the ‘EveResult’ class.  The ‘EveResult’ class simply contains the following:

[php]class EveResult {
var $name; // the name of the result set
var $count; // the number of rows in $rows
var $time; // the currentTime node
var $cachedUntil; // the cachedUntil node
var $api_version; // the api version
var $raw_response; // the actual XML response from the server

var $timeOffset; // the time offset between currentTime and time()
var $localExpiration; // timeOffset added to cachedUntil

var $rows = array(); // associative array of row data

function toHtmlTable() { /* code snipped */ }
}[/php]

All the functions of the EveAPI class implement a session based server-side caching, and retrieve ‘cachedUntil’ results from this until the ‘cachedUntil’ time has passed.

I haven’t written much code yet to actually do what my buddy asked for, but so far, I’ve got a fully functional ‘EveAPI Class’ in PHP5 (Not sure if it’s PHP4 compatible?).

I intend to release the ‘EveAPI Class’ to the general public once it’s been tested a bit more and I’ve added a couple more things to it — right now, all the functions are targetted toward corporation data only (‘/corp/’ page requests).  I intend to add the ‘/char/’ page requests, shortly.

6 comments for “Eve Online API and PHP

  1. August 8, 2008 at 7:44 am

    Hello,

    I am very intrested in this project of yours because the data could be output onto my corps website that I am building to keep basic corp informations on the server and public, but also it would be interesting to be able to host member web pages for their characters that allows us to see what each of the characters has trained as you could on ineve.net or whatever its called. And though we could do the same thing with ineve some members dont wish for the information to be public and this would keep it in house. I would be interested to see were this project went in the future.

  2. Rene van Koll
    August 15, 2008 at 5:43 am

    Hi there,

    And yet another endorsement! I’d very much like to see that code and incorporate it into some of my own stuff (that I’ve yet to write).

    Good luck on writing the rest, and here’s looking forward to it!

  3. PHP Noob
    November 4, 2008 at 1:11 pm

    Wow i hope this is going good. Any updates :) looking to do just this with the char section first.

  4. hopeful
    August 25, 2009 at 8:10 am

    Is there an update for this…I have no idea what it means but it does what I would like to have. :)

  5. August 25, 2009 at 9:03 am

    This project has been abandoned – due to a lack of interest during it’s development.

  6. October 19, 2009 at 1:57 am

    there is a german project http://www.eve-online-manager.de that aims to provide also stuff for Corps, but for now there is only stuff for characters

Leave a Reply