PHP code example of almostinteractive / mixer-php-client

1. Go to this page and download the library: Download almostinteractive/mixer-php-client 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/ */

    

almostinteractive / mixer-php-client example snippets


$mixerGuzzleClient = new MixerGuzzleClient('MY_CLIENT_ID');
$apiClient = new MixerApi('MY_CLIENT_ID', 'MY_CLIENT_SECRET', $mixerGuzzleClient);


$scope = [
    'channel:analytics:self',
    'channel:details:self',
    'user:details:self'
];
$scope = implode('%20', $scope);
$authUrl = $apiClient->getOauthApi()->getAuthUrl('http://localhost/callback.php', 'code', $scope, true, null);


$response = $apiClient->getOauthApi()->getUserAccessToken($code, 'http://localhost/callback.php');
$token = json_decode($response->getBody()->getContents(), true);
$accessToken = $token['access_token'];
$refreshToken = $token['refresh_token'];

$response = $apiClient->getUsersApi()->getUserByAccessToken($accessToken);
$userData = json_decode($response->getBody()->getContents(), true);