PHP code example of mglinski / eve-api-php

1. Go to this page and download the library: Download mglinski/eve-api-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mglinski / eve-api-php example snippets




// characterID of a character provided by the API Key
$characterID = 99999999;

// Create an ApiKey Object with the known key details
$api_key = new Eve\Api\ApiKey('KEY_ID', 'KEY_vCODE');

// Execute an API request.
$char = Eve\Character::CharacterSheet($characterID, $api_key);

// get the data returned from the API call.
echo $char->name;



// Imports
use Eve\Api\Config as EveApiConfig;
use Eve\Api\ApiKey as EveApiKey;
use Eve\Character as CharacterApi;

use Monolog\Logger;
use Monolog\Handler\StreamHandler as LogStreamHandler;

// EveApi Config Object
$config = EveApiConfig::Instance();
$config->user_agent = 'MY SITE NAME (v1.0) [[email protected]]';
$config->log_handler = new LogStreamHandler('path/to/your.log', Logger::WARNING);

// Create an ApiKey Object with api key info
$key = new EveApiKey('KEY_ID', 'KEY_vCODE');

// Execute the API request.
$character = CharacterApi::CharacterSheet($characterID, $key);

// Get the character name from the returned data
if (!$key->getKeyError()) {
    echo $character->name;
}
else {
    throw new \Exception('EVE Api Exception: '.$key->getKeyErrorMessage());
}