khaleejinfotech/youtube-data-api-laravel
Composer 安装命令:
composer require khaleejinfotech/youtube-data-api-laravel
包简介
YouTube Metadata normal grabs singular details about a video and its uploader.
README 文档
README
YouTube Metadata normal grabs singular details about a video and its uploader.
Note: This extension works in Laravel 8 and Laravel 9.
INSTALLATION
Run the command: composer require khaleejinfotech/youtube-data-api-laravel to download the package into the Laravel platform.
After you have installed the package, open your Laravel config file config/app.php and add the following lines.
In the $providers array add the service providers for this package.
Khaleejinfotech\YoutubeDataApi\YoutubeDataApiServiceProvider::class,
Publish the config file with
php artisan vendor:publish --tag="youtube_data_api"
Open the config/youtube_data_api.php in any text editor and add your api key obtained from google developer console.
<?php return [ 'key' => env('YOUTUBE_DATA_API') ];
USAGE
Create a TestController in Laravel using the below command line
php artisan make:controller TestController
Open the app/Http/Controllers/TestController.php in any text editor. To use IP2Location, add the below lines into the controller file.
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use Khaleejinfotech\YoutubeDataApi\YoutubeDataApi; class TestController extends Controller { //Create a fetch function for display public function fetch(){ // Try query the video metadata by video Id $youtubeDataApi = new YoutubeDataApi(); $youtubeDataApi->setVideoID("cT1Df9lpYw8"); $videoData= $youtubeDataApi->fetch(); echo 'VideoID : ' . $videoData->videoId . "<br>"; echo 'Title : ' . $videoData->title . "<br>"; echo 'Description : ' . $videoData->description . "<br>"; echo 'Channel Title : ' . $videoData->channelTitle . "<br>"; echo 'Published At : ' . $videoData->publishedAt ; $thumbnails = $videoData->thumbnails; // Returns array of different thumbnail sizes. $defaultImageUrl = $thumbnails->default->url; $defaultImageWidth = $thumbnails->default->width; $defaultImageHeight = $thumbnails->default->height; $mediumImageUrl = $thumbnails->medium->url; $mediumImageWidth = $thumbnails->medium->width; $mediumImageHeight = $thumbnails->medium->height; $highImageUrl = $thumbnails->high->url; $highImageWidth = $thumbnails->high->width; $highImageHeight = $thumbnails->high->height; } }
Add the following line into the routes/web.php file.
Route::get('test', [TestController::class,'fetch');
Enter the URL localhost:8000/test and run. You should see the metadata of videoID cT1Df9lpYw8.
khaleejinfotech/youtube-data-api-laravel 适用场景与选型建议
khaleejinfotech/youtube-data-api-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 08 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 khaleejinfotech/youtube-data-api-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 khaleejinfotech/youtube-data-api-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 22
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-23