PHP code example of th3shadowbroker / spiget4php

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

    

th3shadowbroker / spiget4php example snippets



use de\m4taiori\spiget4php\SpigetAPI as SpigetAPI;

//Yes you can use 'new' but getInstance() is a better way because you don't have to create a ton of instances.
$spiget = SpigetAPI::getInstance();

/*
 * Some functions use optional arguments/parameters. Use null if you want to use the default value
 * defined by the spiget-web-api.
 * 
 * Nearly all functions in this lib throw SpigetExceptions if something's going horribly wrong or is just invalid. However
 * if you want to receive nulls instead of exceptions you can disable exceptions by using setThrowExceptions()
 * at any time.
 */

//Let's get a list of the categories
$categories = $spiget->getCategoryList();

//All results will be returned as PHP assoc.-array
var_dump($categories); //<-- Let's see the result as it is in PHP