PHP code example of sevenpluss / twitch-api

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

    

sevenpluss / twitch-api example snippets




namespace YourApp\Http\Controllers;

use Sevenpluss\TwitchApi\Services\TwitchApi;
use Sevenpluss\TwitchApi\Services\ClientSettings;

class VideoController
{
    protected $api;
    
    public function __construct() 
    {
        // make a self extended ClientSettings class with custom settings
        $settings = new ClientSettings('client_id', 'client_secret', 'redirect_url');
        
        $this->api = new TwitchApi($settings);
        
    }
    
    public function index()
    {
        $videos = $this->api->videos()->getVideosByUserId('31239503')->data();
        
        return compact('videos');
    }
}