PHP code example of mtxserv / curse-api
1. Go to this page and download the library: Download mtxserv/curse-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/ */
mtxserv / curse-api example snippets
use CurseApi\CurseClient;
use GuzzleHttp\Exception\GuzzleException;
$client = new CurseClient([
'api_key' => 'YOUR_API_KEY', // https://console.curseforge.com/?#/api-keys
]);
try {
// Get Games
$response = $client->get('/v1/games');
$json = json_decode($response->getBody()->getContents(), \JSON_THROW_ON_ERROR);
print_r($json);
// Get All the Mods 7
$response = $client->get('/v1/games/mods/426926');
$json = json_decode($response->getBody()->getContents(), \JSON_THROW_ON_ERROR);
print_r($json);
// Get All the Mods 7 - Files
$response = $client->get('/v1/games/mods/426926/files');
$json = json_decode($response->getBody()->getContents(), \JSON_THROW_ON_ERROR);
print_r($json);
} catch (GuzzleException $e) {
echo $e->getMessage();
exit;
}
sh
php composer.phar