Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require TBoileau/twitch-api
Open a command console, enter your project directory and execute the following command to download the Twitch Cli :
$ php bin/console twitch:install -v 1.1.21 -d Linux_x86_64
Options :
- --version (or -v) : Pick one of the available versions (default: 1.1.12), you can check all of the available versions here.
- --distribution (or -d) : Choose the right distribution for your system (Linux_x86_64, Linux_arm64, Darwin_x86_64, Darwin_arm64, Windows_x86_64, Windows_i386).
TWITCH_MOCK_SERVER_PORT=8080 # you can leave it empty if you don't want to use the mock server
TWITCH_API_HOST=https://api.twitch.tv # or http://localhost:8080 if you want to use the mock server
TWITCH_API_BASE_URI=/helix # or /mock if you want to use the mock server
TWITCH_API_CLIENT_ID=your_client_id # you can leave it empty if you use the mock server
TWITCH_API_CLIENT_SECRET=your_client_secret # you can leave it empty if you use the mock server
Open a command console, enter your project directory and execute the following command to start the Twitch mock server :
$ php bin/console twitch:serve
<?php
use TBoileau\TwitchApi\Api\TwitchApiFactory;
$twitchApi = TwitchApiFactory::create($accessToken, $_ENV['TWITCH_API_CLIENT_ID']);
$leaderboard = $twitchApi->Bits->getLeaderboard();