PHP code example of aternos / poggit-api

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

    

aternos / poggit-api example snippets



use Aternos\PoggitApi\Client\PoggitAPIClient;

// create an API client. This is the main entry point for the API
$poggitClient = new PoggitAPIClient();

// set a user agent (recommended)
$poggitClient->setUserAgent('aternos/php-poggit-api-example');

$releases = $poggitClient->getReleases("poggit/project");

foreach ($releases as $release) {
    echo $release->getData()->getName() . PHP_EOL;
}

use \Aternos\PoggitApi\Client\SearchOptions;
use \Aternos\PoggitApi\Model\State;
use \Aternos\PoggitApi\Model\CategoryId;

$searchOptions = new SearchOptions();

// Only get approved releases
$searchOptions->setMinStability(State::APPROVED);

// Only show versions of a specific project by name
$searchOptions->setName("AdminTrollV2");

// Only get a specific version of a project
$searchOptions->setName("AdminTrollV2")
              ->setVersion("1.2.1");

// Get releases in a certain category
$searchOptions->setCategory(CategoryId::ADMIN_TOOLS);

// Only show releases by a specific author
$searchOptions->setOwner("JavierLeon9966");

// Only get the latest version of every project
$searchOptions->setLatestOnly(true);

$releases = $poggitClient->getReleases($searchOptions);

$release = $poggitClient->getRelease(1234);

$release = $poggitClient->getLatestReleaseByPluginName("AdminTrollV2");

$release = $poggitClient->downloadVersion("AdminTrollV2", "1.2.1");

$release = $poggitClient->getLatestReleaseByPluginName("AdminTrollV2");

$md5 = $release->getMD5Hash();
$sha1 = $release->getSHA1Hash();