dynamikaweb/yii2-youtube
最新稳定版本:v1.1.1
Composer 安装命令:
composer require dynamikaweb/yii2-youtube
包简介
environment for use with youtube, has validators, helpers, apis, widgets...
关键字:
README 文档
README
Installation
The preferred way to install this extension is through composer.
Either run
$ composer require dynamikaweb/yii2-youtube "*"
or add
"dynamikaweb/yii2-youtube": "*"
to the require section of your composer.json file.
Usage
Add it to your components
add to your components
'components' => [ ... 'youtube' => [ 'class' => \sr1871\youtubeApi\components\YoutubeApi::className(), 'api_config' => [ 'clientId' => 'your Oauth Client Id, you can get it from google console', 'clientSecret' => 'your Oauth Client Secret, you can get it from google console', 'scopes' => ['scopes that you going to use', 'as array'], ], 'channel' = 'youtube channel, which will be consulted' ], ... ]
generate your access token
An advantage of this component is that you only have to generate your access token once.
Create an action in any controller
public function actionYoutubeValidation() { if(Yii::$app->request->get('validate')){ return $this->redirect(Yii::$app->youtube->validationGet(Yii::$app->urlManager->createAbsoluteUrl('/site/youtube-validation'))); } if(Yii::$app->request->get('code')){ Yii::$app->youtube->validationPost(Yii::$app->urlManager->createAbsoluteUrl('/site/youtube-validation')); } else { Yii::$app->session->setFlash('success', 'The access token was generated'); return $this->redirect('index'); } }
To validate access to the action by passing the validate parameter come true.
This will access google to do the validation and it will return to the same action by passing the parameter code with the Access Token.
Example:
https://yoursite.com.br/site/youtube-validation?validate=1
Example
Yii::$app->youtube->setParts(['snippet', 'recordingDetails', 'id'])->listVideos(['id' => 'someId'])
You can pass in setParts(), the parts that you want, if you don't want the default parts. For more information of every method and how do it, read the PhpDOC of component's methods
统计信息
- 总下载量: 1.21k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2021-01-15