corbpie/yt-api
Composer 安装命令:
composer require corbpie/yt-api
包简介
A PHP YouTube API wrapper
README 文档
README
Just a PHP YouTube API wrapper for searching videos and getting channel/video/playlist data and information.
Usage
composer require corbpie/yt-api
Put your YouTube API key at line 9 of src/YTAPI.php
Use the class with:
require_once('vendor/autoload.php'); use Corbpie\YouTubeApiClass\YTAPI; $yt = new YTAPI();
Searching videos
Search a channel
This will gets 25 videos from the NBA channel with the query "Jordan" sorted by view count
$yt->setChannelId('UCWJ2lWNubArHWmf3FIHbfcQ'); $yt->getVideoSearch('Jordan', 'viewCount', 25);
Search everywhere
Just dont set channelId to search all of YouTube (Not a channel specific)
$yt->getVideoSearch('Jordan', 'viewCount', 25);
Get latest videos from a channel
Get 25 videos sorted by date published (recent -> oldest)
$yt->setChannelId('UCWJ2lWNubArHWmf3FIHbfcQ'); $yt->getVideoSearch('', 'date', 25);
Order types:
- date
- rating
- relevance
- title
- videoCount
- viewCount
results amount is capped at max 50.
Video information
$yt->setVideoId('1fjhIWJSxfw'); $yt->getVideoData();
Channel information
$yt->setChannelId('UCWJ2lWNubArHWmf3FIHbfcQ'); $yt->getChannelData();
Get channel playlists (Requires channelId to have been set):
$call->getChannelPlaylistsData(50);
Playlist videos
$yt->setPlaylistId('UCWJ2lWNubArHWmf3FIHbfcQ'); $yt->getPlaylistsData();
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-08-15