PHP code example of mentos1386 / opencrest

1. Go to this page and download the library: Download mentos1386/opencrest 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/ */

    

mentos1386 / opencrest example snippets


use OpenCrest\OpenCrest;
$token = "Access Token you got from OAuth authentication | Required only for Authenticated resources";
OpenCrest::setToken($token);

// Get list of constellations
$constellations = OpenCrest::Constellations->get();

// You can then foreach list to get more details on constellations
foreach ($constellations as $constellation) {
    // This will make show($id) request for every object.
    //Beware, that OpenCrest::[something]->get() can be very long and that making get request on every item 
    // will make alot of reqquests.
    var_dump($constellation->get);

}
// Get specific constellation
$id = 20000002;
$constellation = OpenCrest::Constellations->get($id);

// Same with planets
$id = 40000017;
$planet = OpenCrest::Planets->get($id);

// Or alliances
$id = 99000006;
$alliance = OpenCrest::Alliances->get($id)->description;

// Get list of alliances
$alliances = OpenCrest::Alliances->get();

// Go to specific page
$alliances = OpenCrest::Alliances->page(2);

// Go to next page
// Using allrady recived object to know which page is next.
$alliances = $alliances->nextPage();

// Go to previouse page
// Using allrady recived object to know which page is previous.
$alliances = $alliances->previousPage();