Laravel PHP 为 Youtube 数据 API 提供外观/封装
Laravel PHP 面向 YouTube 数据 API v3 的门面/包装 (非 OAuth)
php5-branch在控制台中运行以下命令,以将包下载到您的项目中:
composer require alaouy/youtube在 /config/app.php 中添加 YoutubeServiceProvider (Laravel 使用 Alaouy\Youtube\Facades\Youtube::class,
Publish config settings:bach $ php artisan vendor:publish --provider="Alaouy\Youtube\YoutubeServiceProvider"
Set your YouTube API key in the file:
外壳 /config/youtube.php
Or in the .env file外壳 YOUTUBE_API_KEY = 密钥
Or you can set the key programmatically at run time :
``` php Youtube::setApiKey('KEY'); ```
## Usage
``` php // 使用 Alaouy\Youtube\Facades\Youtube; // 返回一个标准 PHP 对象 $video = Youtube::getVideoInfo('rie-hPVJ7Sw'); // 从数组中获取多个视频信息 $videoList = Youtube::getVideoInfo(['rie-hPVJ7Sw', 'iKHTawgyKWQ']); // 获取本地化的视频信息 $video = Youtube::getLocalizedVideoInfo('vjF9GgrY9c0', 'pl'); // 根据 videoId 获取评论线索 $commentThreads = Youtube::getCommentThreadsByVideoId('zwiUB_Lh3iA'); // 获取某个国家的热门视频,返回一个 PHP 对象数组 $videoList = Youtube::getPopularVideos('us');
// 搜索播放列表、频道和视频。返回 PHP 对象数组 $results = Youtube::search('Android');
// 仅搜索视频,返回 PHP 对象数组 $videoList = Youtube::searchVideos('Android');
// 仅搜索指定频道中的视频,返回 PHP 对象数组 $videoList = Youtube::searchChannelVideos('keyword', 'UCk1SpWNzOs4MYmr0uICEntg', 40);
// 列出指定频道中的视频,返回 PHP 对象数组 $videoList = Youtube::listChannelVideos('UCk1SpWNzOs4MYmr0uICEntg', 40);
[](https://www.paypal.me/malaouy)暂无开放 Issues,或尚未同步最近议题。