PHP code example of rayblair / spacetradersphp

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

    

rayblair / spacetradersphp example snippets


    // Include composer autoload, if oad.php';

    // Import the SpaceTradersPHP class
    use RayBlair\SpaceTradersPHP\SpaceTradersPHP;

    // Initial a client instance
    $client = new SpaceTradersPHP('token', 'username');

    // Will return the game status
    echo $client->game->status()->status;

    // kill php script
    die();

    // Include composer autoload, if     // Import the SpaceTradersPHP class
    use RayBlair\SpaceTradersPHP\SpaceTradersPHP;

    // Initial a client instance
    $client = new SpaceTradersPHP('token', 'username');

    // Get Game Status
    $client->game->status();

    // Create User Token
    $client->users->token('username');

    // Show User
    $client->users->get('username');

    // Get All Active Flight Plans
    $client->flightPlans->all('OE');

    // Get existing Flight Plan
    $client->flightPlans->get('username', 'flight_plan_id');

    // Create Flight Plan
    $client->flightPlans->create('username', 'ship_id', 'destination');

    // Get available loans
    $client->loans->all();

    // Get loans
    $client->loans->get('username');

    // Takeout loan
    $client->loans->takeout('username', 'STARTUP');

    // Payoff loan
    $client->loans->payoff('username', 'loan_id');

    // Get Location
    $client->locations->get('OE-UC');

    // Get Ships at Location
    $client->locations->ships('OE-UC');

    // Get Locations in System
    $client->systems->all();

    // Get Locations in System
    $client->systems->get('OE');

    // Get Marketplace in Location
    $client->locations->marketplace('OE-UC');

    // Purchase Order
    $client->orders->purchase('username', 'ship_id', 'FUEL', 20);

    // Sell Order
    $client->orders->sell('username', 'ship_id', 'FUEL', 20);

    // Show All Ships
    $client->ships->all();

    // Show Player's Ships
    $client->ships->get();

    // Get Ship by ID
    $client->ships->get('ship_id');

    // Purchase Ship
    $client->ships->purchase('username', 'OE-PM-TR', 'JW-MK-I');

    // Jettison Ship's Cargo
    $client->ships->jettison('username', 'ship_id', 'FUEL', 20);

    // Scrap Ship
    $client->ships->scrap('username', 'ship_id');