PHP code example of fuitad / gazelle

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

    

fuitad / gazelle example snippets


use Gazelle\Gazelle;

$gazelle = new Gazelle('https://your-kitsu-server.example.com/api');

// Authenticate
$gazelle->logIn('[email protected]', 'password');

// List all open projects
$projects = $gazelle->project->allOpenProjects();

// Get all shots for a project
$shots = $gazelle->shot->allShotsForProject($projects[0]);

// Log out
$gazelle->logOut();

// Password login
$tokens = $gazelle->logIn('[email protected]', 'password');

// MFA (TOTP)
$tokens = $gazelle->logIn('[email protected]', 'password', totp: '123456');

// Use an existing token
$gazelle->setToken('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...');

// Or with refresh token
$gazelle->setToken([
    'access_token'  => 'eyJ...',
    'refresh_token' => 'eyJ...',
]);

// Refresh the access token manually
$gazelle->refreshAccessToken();

// Log out
$gazelle->logOut();

$gazelle = new Gazelle(
    host: 'https://kitsu.example.com/api',
    sslVerify: true,                          // Verify SSL certificates
    useRefreshToken: true,                    // Auto-refresh on token expiry
    callbackNotAuthenticated: function($client, $path) {
        // Called when a 401 is received.
        // Return true to retry the request, false to throw NotAuthenticatedException.
        return false;
    },
);

// Change host at runtime
$gazelle->setHost('https://other-kitsu.example.com/api');

// Check connectivity
$gazelle->hostIsUp();    // bool
$gazelle->hostIsValid(); // bool (checks /api endpoint responds)