mtxserv/curse-api

用于与 CurseForge API 交互的 PHP 库。

v1.0.3 2022-07-06 10:23 UTC

This package is auto-updated.

Last update: 2024-09-06 15:21:39 UTC


README

Latest Stable Version

Curse Api 是一个基于 Guzzle 的现代 PHP 库,用于 CurseForge

依赖项

安装

Curse Api 的安装仅支持使用 Composer 进行官方安装

php composer.phar require mtxserv/curse-api

示例

<?php

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;
}