|
@@ 33-58 (lines=26) @@
|
| 30 |
|
* @param $url |
| 31 |
|
* @return SimpleXMLElement|null |
| 32 |
|
*/ |
| 33 |
|
function makeApiRequest($url) |
| 34 |
|
{ |
| 35 |
|
$logger = new Logger('eveApi'); |
| 36 |
|
$logger->pushHandler(new StreamHandler(__DIR__ . '/../../log/libraryError.log', Logger::DEBUG)); |
| 37 |
|
try { |
| 38 |
|
// Initialize a new request for this URL |
| 39 |
|
$ch = curl_init($url); |
| 40 |
|
// Set the options for this request |
| 41 |
|
curl_setopt_array($ch, array( |
| 42 |
|
CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirect |
| 43 |
|
CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched data |
| 44 |
|
CURLOPT_SSL_VERIFYPEER => true, // Do not verify the SSL certificate |
| 45 |
|
CURLOPT_USERAGENT => 'Dramiel Discord Bot - https://github.com/shibdib/Dramiel', // Useragent |
| 46 |
|
CURLOPT_TIMEOUT => 15, |
| 47 |
|
)); |
| 48 |
|
// Fetch the data from the URL |
| 49 |
|
$data = curl_exec($ch); |
| 50 |
|
// Close the connection |
| 51 |
|
curl_close($ch); |
| 52 |
|
// Return a new SimpleXMLElement based upon the received data |
| 53 |
|
return new SimpleXMLElement($data); |
| 54 |
|
} catch (Exception $e) { |
| 55 |
|
$logger->error('EVE API Error: ' . $e->getMessage()); |
| 56 |
|
return null; |
| 57 |
|
} |
| 58 |
|
} |
| 59 |
|
|
| 60 |
|
/** |
| 61 |
|
* @return mixed|null |
|
@@ 165-192 (lines=28) @@
|
| 162 |
|
* @return mixed |
| 163 |
|
*/ |
| 164 |
|
////Char ID to char data via CCP |
| 165 |
|
function characterDetails($characterID) |
| 166 |
|
{ |
| 167 |
|
$logger = new Logger('eveESI'); |
| 168 |
|
$logger->pushHandler(new StreamHandler(__DIR__ . '/../../log/libraryError.log', Logger::DEBUG)); |
| 169 |
|
|
| 170 |
|
try { |
| 171 |
|
// Initialize a new request for this URL |
| 172 |
|
$ch = curl_init("https://esi.tech.ccp.is/latest/characters/{$characterID}/"); |
| 173 |
|
// Set the options for this request |
| 174 |
|
curl_setopt_array($ch, array( |
| 175 |
|
CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirect |
| 176 |
|
CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched data |
| 177 |
|
CURLOPT_TIMEOUT => 8, |
| 178 |
|
CURLOPT_SSL_VERIFYPEER => true, // Do not verify the SSL certificate |
| 179 |
|
)); |
| 180 |
|
// Fetch the data from the URL |
| 181 |
|
$data = curl_exec($ch); |
| 182 |
|
// Close the connection |
| 183 |
|
curl_close($ch); |
| 184 |
|
$data = json_decode($data, TRUE); |
| 185 |
|
|
| 186 |
|
} catch (Exception $e) { |
| 187 |
|
$logger->error('EVE ESI Error: ' . $e->getMessage()); |
| 188 |
|
return null; |
| 189 |
|
} |
| 190 |
|
|
| 191 |
|
return $data; |
| 192 |
|
} |
| 193 |
|
|
| 194 |
|
/** |
| 195 |
|
* @param string $systemID |
|
@@ 238-265 (lines=28) @@
|
| 235 |
|
* @return mixed |
| 236 |
|
* Return system information |
| 237 |
|
*/ |
| 238 |
|
function systemDetails($systemID) |
| 239 |
|
{ |
| 240 |
|
$logger = new Logger('eveESI'); |
| 241 |
|
$logger->pushHandler(new StreamHandler(__DIR__ . '/../../log/libraryError.log', Logger::DEBUG)); |
| 242 |
|
|
| 243 |
|
try { |
| 244 |
|
// Initialize a new request for this URL |
| 245 |
|
$ch = curl_init("https://esi.tech.ccp.is/latest/universe/systems/{$systemID}/"); |
| 246 |
|
// Set the options for this request |
| 247 |
|
curl_setopt_array($ch, array( |
| 248 |
|
CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirect |
| 249 |
|
CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched data |
| 250 |
|
CURLOPT_TIMEOUT => 8, |
| 251 |
|
CURLOPT_SSL_VERIFYPEER => true, // Do not verify the SSL certificate |
| 252 |
|
)); |
| 253 |
|
// Fetch the data from the URL |
| 254 |
|
$data = curl_exec($ch); |
| 255 |
|
// Close the connection |
| 256 |
|
curl_close($ch); |
| 257 |
|
$data = json_decode($data, TRUE); |
| 258 |
|
|
| 259 |
|
} catch (Exception $e) { |
| 260 |
|
$logger->error('EVE ESI Error: ' . $e->getMessage()); |
| 261 |
|
return null; |
| 262 |
|
} |
| 263 |
|
|
| 264 |
|
return $data; |
| 265 |
|
} |
| 266 |
|
|
| 267 |
|
/** |
| 268 |
|
* @param string $regionID |
|
@@ 272-299 (lines=28) @@
|
| 269 |
|
* @return mixed |
| 270 |
|
* Return region information |
| 271 |
|
*/ |
| 272 |
|
function regionDetails($regionID) |
| 273 |
|
{ |
| 274 |
|
$logger = new Logger('eveESI'); |
| 275 |
|
$logger->pushHandler(new StreamHandler(__DIR__ . '/../../log/libraryError.log', Logger::DEBUG)); |
| 276 |
|
|
| 277 |
|
try { |
| 278 |
|
// Initialize a new request for this URL |
| 279 |
|
$ch = curl_init("https://esi.tech.ccp.is/latest/universe/regions/{$regionID}/"); |
| 280 |
|
// Set the options for this request |
| 281 |
|
curl_setopt_array($ch, array( |
| 282 |
|
CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirect |
| 283 |
|
CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched data |
| 284 |
|
CURLOPT_TIMEOUT => 8, |
| 285 |
|
CURLOPT_SSL_VERIFYPEER => true, // Do not verify the SSL certificate |
| 286 |
|
)); |
| 287 |
|
// Fetch the data from the URL |
| 288 |
|
$data = curl_exec($ch); |
| 289 |
|
// Close the connection |
| 290 |
|
curl_close($ch); |
| 291 |
|
$data = json_decode($data, TRUE); |
| 292 |
|
|
| 293 |
|
} catch (Exception $e) { |
| 294 |
|
$logger->error('EVE ESI Error: ' . $e->getMessage()); |
| 295 |
|
return null; |
| 296 |
|
} |
| 297 |
|
|
| 298 |
|
return $data; |
| 299 |
|
} |
| 300 |
|
|
| 301 |
|
/** |
| 302 |
|
* @param string $corpName |
|
@@ 370-397 (lines=28) @@
|
| 367 |
|
* @return mixed |
| 368 |
|
*/ |
| 369 |
|
////Corp ID to corp data via CCP |
| 370 |
|
function corpDetails($corpID) |
| 371 |
|
{ |
| 372 |
|
$logger = new Logger('eveESI'); |
| 373 |
|
$logger->pushHandler(new StreamHandler(__DIR__ . '/../../log/libraryError.log', Logger::DEBUG)); |
| 374 |
|
|
| 375 |
|
try { |
| 376 |
|
// Initialize a new request for this URL |
| 377 |
|
$ch = curl_init("https://esi.tech.ccp.is/latest/corporations/{$corpID}/"); |
| 378 |
|
// Set the options for this request |
| 379 |
|
curl_setopt_array($ch, array( |
| 380 |
|
CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirect |
| 381 |
|
CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched data |
| 382 |
|
CURLOPT_TIMEOUT => 8, |
| 383 |
|
CURLOPT_SSL_VERIFYPEER => true, // Do not verify the SSL certificate |
| 384 |
|
)); |
| 385 |
|
// Fetch the data from the URL |
| 386 |
|
$data = curl_exec($ch); |
| 387 |
|
// Close the connection |
| 388 |
|
curl_close($ch); |
| 389 |
|
$data = json_decode($data, TRUE); |
| 390 |
|
|
| 391 |
|
} catch (Exception $e) { |
| 392 |
|
$logger->error('EVE ESI Error: ' . $e->getMessage()); |
| 393 |
|
return null; |
| 394 |
|
} |
| 395 |
|
|
| 396 |
|
return $data; |
| 397 |
|
} |
| 398 |
|
|
| 399 |
|
/** |
| 400 |
|
* @param string $allianceID |