mmg/youtube
最新稳定版本:v1.0.2
Composer 安装命令:
composer require mmg/youtube
包简介
Wrapper class for the mmg group to consume Youtube Api.
README 文档
README
Background
This is just a "wrapper class" built on top of the "Google SDK" to minimize the effort of integrating the "Youtube" api into your projects.
Pre Requisite
- Xampp/Wampp or Mamp server must be installed.
- Composer is installed and configured properly.
- Minimum PHP 7.2 (Not tested below or with later versions).
- Google Developer Console account.
Setup Google Developer Console Project
- Sign in to Google Developer Console.
- Create "New Project" usually option is available between google cloud logo and the search bar.
- Enter "Project Name" and select "Organization" depending upon your account.
- Click blue "Create" button.
- Configure "0Auth consent screen" by filling asked details and click "Save and continue" button.
-
Add the required Scopes you will be requesting from the user:
https://www.googleapis.com/auth/youtube.readonly
https://www.googleapis.com/auth/youtube.force-ssl
click "Save and continue" after adding above scopes into consent screen.
Note: If scopes are not available in your project click "Enable API & Services" button and enable "Youtube Data API" for your project. - Add "Test users" and click "Save and continue" button.
- Click "Credentials" option provided in left "Navigation Panel".
- Click "+ Create Credentials" button and choose "API Key" & copy it.
- Create "OAuth client ID" while you are on the "Credentials" page and configure "Redirect URIs".
- Click the little "Download Icon" under the heading "OAuth 2.0 Client IDs" and download config file.
- Make sure you have "API Key" and "Config JSON" file on this step.
Example Code
https://github.com/shahzaib91/youtube-wrapper-exampleSetup Library
- Run command
composer require mmg/youtube. - Add
require __DIR__.'/vendor/autoload.php';on top of your php file.
Functions Description
| Function Name | Description |
|---|---|
public function prepare($name, $scopes, $configJsonPath, $apiKey)
|
Function to config client via wrapper class |
public function getAuthUrl()
|
Function to get auth url for authentication |
public function getAccessToken($code)
|
Function to fetch access token and set it to client |
public function setAccessToken($accessTokenJson)
|
Function sets access token to google client object |
private function parseAccessTokenJson($accessTokenJson)
|
Helper function to abstractedly perform json parsing |
public function getChannelsList()
|
Function to retrieve list of available channels owned by authenticated user |
public function getVideosList($channelId, $maxItems = 12)
|
Function to retrieve list of videos |
public function getVideoDetail($videoId)
|
Function to retrieve video details |
public function getVideoComments($videoId, $maxItems = 12)
|
Function to retrieve video comments and replies |
public function getVideoComments($videoId, $maxItems = 12)
|
Function is helping in tagging right reply to right comment by id |
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-12