PHP code example of simply-stream / twitch-api

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

    

simply-stream / twitch-api example snippets


$client = new Client();
// Same for the request factory, it just needs to implement the RequestFactoryInterface&StreamFactoryInterface.
// Optionally the UriFactoryInterface, too, if you want to use the same object for the UriFactory.
$requestFactory = new RequestFactory();

$apiClient = new ApiClient(
    $client,
    $requestFactory,
    new \CuyZ\Valinor\MapperBuilder(),
    $requestFactory,
    ['clientId' => 'YOUR_CLIENT_ID', 'webhook' => ['secret' => 'YOUR_SECRET']]
);

$usersApi = new UsersApi($apiClient)
$response = $usersApi->getUsers(logins: ['some_login_name'], accessToken: $accessToken);

foreach($response->getData() as $user) {
    echo $user->getDisplayName();
}