PHP code example of aternos / blob-build-api

1. Go to this page and download the library: Download aternos/blob-build-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 / blob-build-api example snippets



use Aternos\BlobBuild\Client\BlobBuildAPIClient;

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

// set a user agent (recommended)
$client->setUserAgent('aternos/php-blob-build-api-example');

$projects = $client->listProjects();

foreach ($projects as $project) {
    echo "Project " . $project->getData()->getName() . " by " . $project->getData()->getOwner() . PHP_EOL;
}

$projects = $client->searchProjects("sound");

foreach ($projects as $project) {
    echo "Project " . $project->getData()->getName() . " by " . $project->getData()->getOwner() . PHP_EOL;
}

$project = $client->getProject("SoundMuffler");
echo "Project " . $project->getData()->getName() . PHP_EOL;

$result = $client->getProjectBuilds("SoundMuffler");
foreach ($result as $channel => $builds) {
    echo "Channel: " . $channel . PHP_EOL;
    foreach ($builds as $build) {
        echo " - Build " . $build->getData()->getBuildId() . PHP_EOL; 
    }
}

// or with the project wrapper
$project = $client->getProject("SoundMuffler");
$result = $project->getBuilds();

$build = $client->getLatestProjectBuildInChannel("SoundMuffler", "Dev");
echo "Build " . $build->getData()->getBuildId() . PHP_EOL;

// Or with the project wrapper
$project = $client->getProject("SoundMuffler");
// Either pick a channel
$build = $project->getLatestBuildInChannel("Dev");
// Or use the default channel
$build = $project->getLatestBuildInDefaultChannel()

$build = $client->getProjectBuild("SoundMuffler", "Dev", 1);
echo "Build " . $build->getData()->getBuildId() . PHP_EOL;

// Or with the project wrapper
$project = $client->getProject("SoundMuffler");
$build = $project->getBuild("Dev", 1);