tambait / php-youtube-api
PHP 对 Youtube 数据 API v3 的包装器
Requires
- php: >=5.3
- ext-curl: *
Requires (Dev)
- phpunit/phpunit: ^4.5 || ^5.0.5
README
注意
此项目(作为独立分支)被创建,因为原始项目 Madcoda PHP Youtube API 似乎已被放弃,并且由于 YouTube API 的变化(invideoPromotion 部分的弃用)而破坏了代码。
版本 1.2.5 修复了此问题。
安装
在您的 PHP 项目中的命令行 shell 中运行以下命令
$ composer require tambait/php-youtube-api:^1.2
或者,您可以手动编辑 composer.json,然后运行 composer update
"require": {
"tambait/php-youtube-api": "^1.2"
}
以下是从 原始项目 的 README.md 文件的部分内容 / 描述。
A basic PHP wrapper for the Youtube Data API v3 ( Non-OAuth ). Designed to let devs easily fetch public data (Video, Channel, Playlists info) from Youtube. No 3rd party dependancy. (except PHPUnit)
The reason of returning the decoded JSON response directly is that you only need to read the Google API doc to use this library, instead of learning my set of API again (Keep it simple).
Well...actually some parameters are missing in this library, because I don't need them at this point, if you desire a particular feature please file an issue here :)
Currently I will not consider adding OAuth endpoints. (those required "authorized request" will not be supported)
需求
- PHP >=5.3
- CURL 扩展在 PHP 中
入门
请阅读关于如何使用此库与 PHP with composer、Laravel 4 和 Laravel 5 的维基。
有关此库中实现的功能,请访问 API 参考
使用纯 PHP(带有 composer)的示例用法
require 'vendor/autoload.php'; $youtube = new Madcoda\Youtube\Youtube(array('key' => '* Your API key here *')); $video = $youtube->getVideoInfo('rie-hPVJ7Sw');
使用 Laravel 4/5 的示例用法
$video = Youtube::getVideoInfo(Input::get('vid', 'dQw4w9WgXcQ');
返回数据的格式
返回的 json 被解码为 PHP 对象(不是数组)。请阅读官方 API 文档的 "参考" 部分。
Youtube 数据 API v3
许可
php-youtube-api 在 MIT 许可证 下授权。