1. Go to this page and download the library: Download raideer/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/ */
raideer / twitch-api example snippets
$client = new GuzzleHttp\Client;
$wrapper = new Raideer\TwitchApi\Wrapper($client);
//You can pass the OAuthResponse object directly
$wrapper->authorize($response);
//Or just pass the access token
$wrapper->authorize($accessToken);
//Or pass both access token and registered scopes array
$wrapper->authorize($accessToken, $registeredScopes);
$wrapper->Channels->getChannel(); //Returns the authenticated user's channel
$wrapper->enableThrottle(true);
// 1 second throttle
$wrapper->setThrottleInterval(1000);
$client = new GuzzleHttp\Client;
$wrapper = new Raideer\TwitchApi\Wrapper($client);
$settings = [
'client_id' => 'myClientId',
'client_secret' => 'myClientSecret',
'redirect_uri' => 'http://localhost',
'state' => 'myUniqueToken123123',
'scope' => ['channel_editor']
];
$oauth = new Raideer\TwitchApi\OAuth($settings);
// You can also add a scope using the addScope method
$oauth->addScope('channel_read');
$url = $oauth->getUrl();
$code = filter_input(INPUT_GET, 'code', FILTER_SANITIZE_STRING);
$response = $oauth->getResponse($code);
$wrapper->authorize($response);
$channel = $wrapper->Channels->getChannel();
echo "I'm currently playing " . $channel->game;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.