PHP code example of yebto / youtube-api

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

    

yebto / youtube-api example snippets


use YoutubeAPI;

$stats = YoutubeAPI::channel('statistics', [
    'channel' => 'UC_x5XG1OV2P6uZZ5FSM9Ttw'
]);

$title = YoutubeAPI::generate('title-generator', [
    'topic'          => 'Laravel queue best practices',
    'keywords'       => ['laravel queue', 'horizon', 'redis'],
    'language'       => 'EN',
    'mood'           => 'energetic',
    'tone'           => 'educational',
    'emojis_mode'    => 'random_inject',
    'hashtags_mode'  => 'end',
    'channel'        => 'UC_x5XG1OV2P6uZZ5FSM9Ttw'
]);

$eng = YoutubeAPI::video('engagement-rate', [
    'video' => 'dQw4w9WgXcQ'
]);

$search = YoutubeAPI::search('videos', [
    'q'                => 'ai music generation',
    'limit'            => 30,
    'sort'             => 'date',
    'duration'         => 'medium',
    'published_after'  => '2024-01-01'
]);

$trending = YoutubeAPI::trending([
    'country'  => 'DE',
    'category' => 20,
    'limit'    => 50
]);
bash
php artisan vendor:publish --tag=youtubeapi-config