badawy / embedly
适用于Embedly api的Laravel 5.*包
v2.0.0
2017-06-07 00:11 UTC
Requires
- php: >=5.4.0
- illuminate/support: 5.1.*|5.2.*|5.3.*|5.4.*
- php-curl-class/php-curl-class: 3.*
README
适用于Laravel 5.*的定制Embedly包
安装
- 通过Composer安装此包。(Laravel 5.4)
{ "require": { "badawy/embedly": "2.*" } }
如果你使用的是Laravel 5.3或更早版本,你应该使用v1.*
{ "require": { "badawy/embedly": "1.*" } }
- 将服务提供者添加到你的
config/app.php
文件中的providers数组中
Badawy\Embedly\EmbedlyServiceProvider::class,
- 将外观添加到你的
config/app.php
文件中
'Embedly' => Badawy\Embedly\Facades\Embedly::class,
- 使用发布命令将包配置复制到本地配置
php artisan vendor:publish --provider="Badawy\Embedly\EmbedlyServiceProvider"
- 在
.env
文件中添加你的API密钥
EMBEDLY_API_KEY=xxxxxxxxxxxxxxxxxx
用法
你可以通过将它们传递为Array而不是String来提取或嵌入单个URL或多个URL
你还可以在提取和嵌入的第二个参数中传递你的查询参数的Array(请参见示例)
(更多信息请参见Embedly文档关于结果、错误和查询参数)(http://embed.ly/docs)
示例
- Embedly提取
$q = Embedly::extract('http://techcrunch.com/2013/03/26/embedly-now-goes-beyond-embedding-with-new-products-extract-display-for-making-sense-of-links-resizing-images/', [ 'maxwidth' => '500' ]);
$q = Embedly::extract([ 'http://techcrunch.com/2013/03/26/embedly-now-goes-beyond-embedding-with-new-products-extract-display-for-making-sense-of-links-resizing-images/', 'http://deadspin.com/5690535/the-bottom-100-the-worst-players-in-nfl-history-part-1', 'http://blog.embed.ly/31814817'],[ 'maxwidth' => '500' ]);
- Embedly嵌入
$q = Embedly::oembed('http://vimeo.com/18150336',[ 'maxwidth' => '500' ]);
$q = Embedly::oembed([ 'https://www.youtube.com/watch?v=jofNR_WkoCE', 'http://soundcloud.com/whichlight/how-to-pronounce-my-name', 'http://vimeo.com/18150336'],[ 'maxwidth' => '500' ]);
然后你可以访问结果
if($q->error){ echo $q->error_message; //Error } else { echo $q->title; //Get result }
待办事项
- 添加'Display' API
许可协议
本模板是开源软件,许可协议为MIT许可
联系
Ahmad Elbadawy