Pheal

From EVEDev
Jump to: navigation, search
Api.pngAPI Resources - Category Home - API Libraries - API Usage Examples - API Method Reference
Pheal
Maintainer: Peter Petermann (eve: Peter Powers)
Stable release: 0.1.7
Development release: git://github.com/ppetermann/pheal.git
OS: Platform independant
License: MIT
Website: http://github.com/ppetermann/pheal/

Pheal is a PHP library for accessing the EVE API, its basically a PHP port of EAAL it uses some metaprogramming foo to ensure it does not need changes when the EVE API is changed. it also contains a simple file cache that can respects the EVE APIs cache timers.

Contents

Installation

git clone git://github.com/ppetermann/pheal.git

make sure your autoloader is able to find the classes (filename example.php matches classname "example" OR

   include "../path/to/Pheal.php"; 
   spl_autoload_register("Pheal::classload"); 
  

in your application, which will use a simple buildin autoloader

Download

If you want you can download directly the repository as zip file: https://github.com/ppetermann/pheal/zipball/master

Usage

Initialize the API Object

  require_once "Pheal/Pheal.php";
  spl_autoload_register("Pheal::classload");
  $pheal = new Pheal("myUserid", "myAPI key"[, "scope for request"]);

the scope is the one used for the API requests, ex. account/char/corp/eve/map/server see API Reference the scope can be changed during runtime and defaults to account

Request Information

  $result = $pheal->ApiPage()

this will return an Object of type PhealResult which then can be used to read the api result

Example 1, getting a list of characters on the account:

  require_once "Pheal/Pheal.php";
  spl_autoload_register("Pheal::classload");
  $pheal = new Pheal("myUserid", "myAPI key"[, "scope for request"]);

 $result = $pheal->Characters();
  foreach($result->characters as $character)
      echo $character->name;

Example 2, getting the id for a given character name

  require_once "Pheal/Pheal.php";
  spl_autoload_register("Pheal::classload");
  $pheal = new Pheal("myUserid", "myAPI key"[, "scope for request"]);

  $pheal->scope = "eve";
  $result = $pheal->CharacterID(array("names" => "Peter Powers"));
  echo $result->characters[0]->characterID;

Using the cache

Pheal comes with a simple file cache, to make use of this cache:

  PhealConfig::getInstance()->cache = new PhealFileCache("/path/to/cache/directory/");

does the magic. if you dont give a path it defaults to $HOME/.pheal/cache

doing a cached request

  require_once "Pheal/Pheal.php";
  spl_autoload_register("Pheal::classload");
  PhealConfig::getInstance()->cache = new PhealFileCache();
  $pheal = new Pheal("myUserid", "myAPI key"[, "scope for request"]);

  $pheal->scope = "eve";
  $result = $pheal->CharacterID(array("names" => "Peter Powers"));
  echo $result->characters[0]->characterID;

now the request will first check if the xml is allready in the cache, if it is still valid, and if so use the cached, only if the cache until of the saved file has expired, it will request again.

Exceptions

Pheal throws an Exception of type PhealAPIException (derived from PhealException) whenever the EVE API returns an error, this exception has an attribute called "code" which is the EVE APIs error code, and also contains the EVE API message as message.

require_once "Pheal/Pheal.php";
  spl_autoload_register("Pheal::classload");
  PhealConfig::getInstance()->cache = new PhealFileCache();
  $pheal = new Pheal("myUserid", "myAPI key"[, "scope for request"]);
  try {
     $pheal->Killlog(array("characterID" => 12345));
  } catch(PhealAPIException $e) {
     echo 'error: ' . $e->code . ' meesage: ' . $e->getMessage();
  }

More Usage Examples

http://github.com/ppetermann/king23_pheal_cli

Bugs

please report bugs at githubs issue tracker http://github.com/ppetermann/pheal/issues

ISK

feel free to send ISK ingame to "Peter Powers"

Retrieved from "?title=Pheal&oldid=6487"
Personal tools