https://github.com/cp6/php-youtube-api
Just a PHP YouTube API wrapper for searching videos and getting channel/video/playlist data.
https://github.com/cp6/php-youtube-api
youtube youtube-api
Last synced: 6 months ago
JSON representation
Just a PHP YouTube API wrapper for searching videos and getting channel/video/playlist data.
- Host: GitHub
- URL: https://github.com/cp6/php-youtube-api
- Owner: cp6
- License: mit
- Created: 2021-08-15T03:13:53.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-04-25T11:49:25.000Z (over 3 years ago)
- Last Synced: 2024-12-07T21:00:24.514Z (over 1 year ago)
- Topics: youtube, youtube-api
- Language: PHP
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP YouTube API wrapper
Just a PHP YouTube API wrapper for searching videos and getting channel/video/playlist data and information.
## Usage
```shell
composer require corbpie/yt-api
```
Put your YouTube API key at line 9 of ```src/YTAPI.php```
Use the class with:
```php
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
```php
$yt->setChannelId('UCWJ2lWNubArHWmf3FIHbfcQ');
$yt->getVideoSearch('Jordan', 'viewCount', 25);
```
**Search everywhere**
Just dont set channelId to search all of YouTube (Not a channel specific)
```php
$yt->getVideoSearch('Jordan', 'viewCount', 25);
```
**Get latest videos from a channel**
Get 25 videos sorted by date published (recent -> oldest)
```php
$yt->setChannelId('UCWJ2lWNubArHWmf3FIHbfcQ');
$yt->getVideoSearch('', 'date', 25);
```
**Order types:**
* date
* rating
* relevance
* title
* videoCount
* viewCount
```results``` amount is capped at max 50.
## Video information
```php
$yt->setVideoId('1fjhIWJSxfw');
$yt->getVideoData();
```
## Channel information
```php
$yt->setChannelId('UCWJ2lWNubArHWmf3FIHbfcQ');
$yt->getChannelData();
```
Get channel playlists (Requires channelId to have been set):
```php
$call->getChannelPlaylistsData(50);
```
## Playlist videos
```php
$yt->setPlaylistId('UCWJ2lWNubArHWmf3FIHbfcQ');
$yt->getPlaylistsData();
```