khaleejinfotech/youtube-data-api-laravel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

khaleejinfotech/youtube-data-api-laravel

最新稳定版本:v1.1

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.

统计信息

  • 总下载量: 22
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固