Introduction
libGameFly is a simple PHP class for interacting with GameFly.com. At the time of this writing, the only functionality exposed by the class is to download, interpret and cache the provided user's GameFly rental cache and return a native PHP array containing the results.
I see this class being useful to blog widget designers looking for a way of exposing a user's rental queue, much like we see with Netflix queues. GameFly, for some reason, has decided not to expose this data in a developer-friendly RSS feed (or any other format for this matter), so this manner of hack is necessary instead.
Using libGameFly In Your Project
libGameFly is incredibly simple to use, and manages it's own caching system to further simplify things (and reduce load on Gamefly's servers.)
To include the class in your project, use PHP's include() command:
include('libGameFly.php');
You'll then need to define the user credentials and assign the class to a local variable, like so:
$GF = new libGameFly('user@email.address','password');
Once you've got libGameFly setup, you can grab the user's queue by using the Get() function. This function will make an HTTP call (using fsockopen) to GameFly.com, download the queue web page, parse it into a native PHP array, and serialize and cache the results in a file named 'gamefly_cache.dat'. Ensure that gamefly_cache.dat is writable or libGameFly will not work.
print_r($GF->Get());
You should see your GameFly queue exposed as a PHP array, with all the bits you might expect.
Requirements
- Known to be compatible with PHP 5.2 and newer. Should be compatible with PHP4 or better, but not confirmed.
- Must be able to make HTTP calls using fsockopen().
- Must be able to write to a file named 'gamefly_cache.dat'.