closes #154 added alliance map support
This commit is contained in:
@@ -32,6 +32,9 @@ SSO_CCP_URL = https://sisilogin.testeveonline.com
|
||||
SSO_CCP_CLIENT_ID =
|
||||
SSO_CCP_SECRET_KEY =
|
||||
|
||||
; CCP XML APIv2
|
||||
CCP_XML = https://api.testeveonline.com
|
||||
|
||||
; SMTP settings (optional)
|
||||
SMTP_HOST = localhost
|
||||
SMTP_PORT = 25
|
||||
@@ -68,6 +71,9 @@ SSO_CCP_URL = https://login.eveonline.com
|
||||
SSO_CCP_CLIENT_ID =
|
||||
SSO_CCP_SECRET_KEY =
|
||||
|
||||
; CCP XML APIv2
|
||||
CCP_XML = https://api.eveonline.com
|
||||
|
||||
; SMTP settings (optional)
|
||||
SMTP_HOST = localhost
|
||||
SMTP_PORT = 25
|
||||
|
||||
@@ -589,13 +589,25 @@ class Sso extends Api\User{
|
||||
], $additionalOptions);
|
||||
|
||||
if( !empty($endpoint) ){
|
||||
$characterData->character = (new Mapper\CrestCharacter($endpoint))->getData();
|
||||
$crestCharacterData = (new Mapper\CrestCharacter($endpoint))->getData();
|
||||
$characterData->character = $crestCharacterData
|
||||
;
|
||||
if(isset($endpoint['corporation'])){
|
||||
$characterData->corporation = (new Mapper\CrestCorporation($endpoint['corporation']))->getData();
|
||||
}
|
||||
|
||||
// IMPORTANT: alliance data is not yet available over CREST!
|
||||
// -> we need to request them over the XML api
|
||||
/*
|
||||
if(isset($endpoint['alliance'])){
|
||||
$characterData->alliance = (new Mapper\CrestAlliance($endpoint['alliance']))->getData();
|
||||
}
|
||||
*/
|
||||
|
||||
$xmlCharacterData = (new Xml())->getPublicCharacterData( (int)$crestCharacterData['id'] );
|
||||
if(isset($xmlCharacterData['alli'])){
|
||||
$characterData->alliance = $xmlCharacterData['alli'];
|
||||
}
|
||||
}
|
||||
|
||||
return $characterData;
|
||||
|
||||
74
app/main/controller/ccp/xml.php
Normal file
74
app/main/controller/ccp/xml.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exodus
|
||||
* Date: 23.05.2016
|
||||
* Time: 18:25
|
||||
*/
|
||||
|
||||
namespace controller\ccp;
|
||||
use Data\Mapper as Mapper;
|
||||
use Controller;
|
||||
use Lib;
|
||||
|
||||
|
||||
class Xml extends Controller\Controller{
|
||||
|
||||
/**
|
||||
* get HTTP request options for API (curl) request
|
||||
* @return array
|
||||
*/
|
||||
protected function getRequestOptions(){
|
||||
$requestOptions = [
|
||||
'timeout' => 4,
|
||||
'user_agent' => $this->getUserAgent(),
|
||||
'follow_location' => false // otherwise CURLOPT_FOLLOWLOCATION will fail
|
||||
];
|
||||
|
||||
return $requestOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* request character data from CCP API
|
||||
* @param int $characterId
|
||||
* @return array
|
||||
*/
|
||||
public function getPublicCharacterData($characterId){
|
||||
$characterData = [];
|
||||
$apiPath = self::getEnvironmentData('CCP_XML') . '/eve/CharacterInfo.xml.aspx';
|
||||
|
||||
$baseOptions = $this->getRequestOptions();
|
||||
$requestOptions = [
|
||||
'method' => 'GET',
|
||||
'content' => [
|
||||
'characterID' => (int)$characterId
|
||||
]
|
||||
|
||||
];
|
||||
|
||||
$requestOptions = array_merge($baseOptions, $requestOptions);
|
||||
$apiResponse = Lib\Web::instance()->request($apiPath, $requestOptions );
|
||||
if(
|
||||
$apiResponse['body'] &&
|
||||
($xml = simplexml_load_string($apiResponse['body']))
|
||||
){
|
||||
|
||||
if(
|
||||
isset($xml->result) &&
|
||||
is_object($rowApiData = $xml->result->children())
|
||||
){
|
||||
foreach($rowApiData as $item){
|
||||
// map attributes to array
|
||||
if(count($item->children()) == 0){
|
||||
$characterData[$item->getName()] = strval($item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data = (new Mapper\CcpCharacterMapper($characterData))->getData();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
37
app/main/data/mapper/ccpcharactermapper.php
Normal file
37
app/main/data/mapper/ccpcharactermapper.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exodus
|
||||
* Date: 23.05.2016
|
||||
* Time: 20:32
|
||||
*/
|
||||
|
||||
namespace data\mapper;
|
||||
|
||||
|
||||
class CcpCharacterMapper extends AbstractIterator {
|
||||
|
||||
|
||||
protected static $map = [
|
||||
'characterID' => ['character' => 'id'],
|
||||
'characterName' => ['character' => 'name'],
|
||||
|
||||
'race' => 'race',
|
||||
|
||||
'bloodlineID' => ['blood' => 'id'],
|
||||
'bloodline' => ['blood' => 'name'],
|
||||
|
||||
'ancestryID' => ['origin' => 'id'],
|
||||
'ancestry' => ['origin' => 'name'],
|
||||
|
||||
'corporationID' => ['corp' => 'id'],
|
||||
'corporation' => ['corp' => 'name'],
|
||||
'corporationDate' => ['corp' => 'date'],
|
||||
|
||||
'allianceID' => ['alli' => 'id'],
|
||||
'alliance' => ['alli' => 'name'],
|
||||
'allianceDate' => ['alli' => 'date'],
|
||||
|
||||
'securityStatus' => 'security'
|
||||
];
|
||||
}
|
||||
@@ -112,7 +112,5 @@ DELETE_ACCOUNT = account_delete
|
||||
|
||||
; API =============================================================================================
|
||||
[PATHFINDER.API]
|
||||
; CCP XML APIv2
|
||||
CCP_XML = https://api.eveonline.com
|
||||
; GitHub Developer API
|
||||
GIT_HUB = https://api.github.com
|
||||
|
||||
Reference in New Issue
Block a user