1. Go to this page and download the library: Download aternos/curseforge-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 / curseforge-api example snippets
use Aternos\CurseForgeApi\Client\CurseForgeAPIClient;
$client = new CurseForgeAPIClient("api-key");
// set a user agent (recommended)
$client->setUserAgent('aternos/php-curseforge-api-example');
$games = $client->getGames();
foreach ($games as $game) {
// like most other methods, this method returns a wrapper
// you can use the getData() method to get the game data
echo $game->getData()->getName() . PHP_EOL;
}
$games = $games->getNextPage();
foreach ($games as $game) {
echo $game->getData()->getName() . PHP_EOL;
}
$options = new ModFilesOptions($mod->getData()->getId());
$options->setGameVersion("1.19.2");
use \Aternos\CurseForgeApi\Client\Options\ModSearch\ModLoaderType;
$options->setModLoaderType(ModLoaderType::FORGE);
$options = new ModFilesOptions(420561);
$options->setGameVersion("1.19.2");
$options->setModLoaderType(ModLoaderType::FORGE);
$files = $client->getModFiles($options);
$file = $client->getModFile(420561, 3787455);
// or
$files = $client->getModFiles([3787455, 3787456]);
$url = $file->getData()->getDownloadUrl();
// or if you don't already have the file object
$url = $client->getModFileDownloadUrl(420561, 3787455);
// Get Minecraft versions
$versions = $client->getMinecraftVersions();
// Get a specific version
$version = $client->getMinecraftVersion("1.19.2");
// Get mod loader versions
$modLoaders = $client->getMinecraftModLoaders();
$modLoaders = $client->getMinecraftModLoaders("1.19.2"); // optionally provide a Minecraft version
$modLoaders = $client->getMinecraftModLoaders(null, true); // show all loaders, including fabric
// get more information about a mod loader version
$version = $client->getMinecraftModLoader("forge-43.2.8");
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.