mpratt/embera
Composer 安装命令:
composer require mpratt/embera
包简介
Oembed consumer library. Converts urls into their html embed code. Supports 150+ sites, such as Youtube, Twitter, vimeo, Instagram etc.
关键字:
README 文档
README
Embera is an Oembed consumer library written in PHP. It takes urls from a text and queries the matching service for information about the media and embeds the resulting html. It supports +150 sites, such as Youtube, Twitter, Livestream, Dailymotion, Instagram, Vimeo and many many more.
Installation
Install the latest stable version with:
$ composer require mpratt/embera:~2.0
Standalone Installation (without Composer)
Download the latest release or clone this repository and include the Àutoloader.php file inside the Embera/src directory.
require '....../Autoloader.php'; use Embera\Embera; $embera = new Embera();
Requirements
- PHP >= 7.0 (It should work on 5.6)
- Curl or allow_url_fopen should be enabled
Basic Usage
The most common or basic example is this one:
use Embera\Embera; $embera = new Embera(); echo $embera->autoEmbed('Hi! Have you seen this video? https://www.youtube.com/watch?v=J---aiyznGQ Its the best!');
The last example returns something like the following text:
Hi! Have you seen this video? <iframe width="459" height="344" src="https://www.youtube.com/embed/J---aiyznGQ?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen ></iframe> Its the best!
You can also inspect urls for their oembed data:
use Embera\Embera; $embera = new Embera(); print_r($embera->getUrlData([ 'https://vimeo.com/374131624', 'https://www.flickr.com/photos/bees/8597283706/in/photostream', ]));
That will return something like this
Array ( [https://vimeo.com/374131624] => Array ( [type] => video [version] => 1.0 [provider_name] => Vimeo [provider_url] => https://vimeo.com/ [title] => VACATION movie [author_name] => Andrey Kasay [author_url] => https://vimeo.com/andreykasay [is_plus] => 0 [account_type] => basic [html] => <iframe src="......."></iframe> [width] => 426 [height] => 240 [duration] => 146 [description] => Остросюжетное кино про жизнь [thumbnail_url] => https://i.vimeocdn.com/video/832478725_295x166.jpg [thumbnail_width] => 295 [thumbnail_height] => 166 [thumbnail_url_with_play_button] => https://i.vimeocdn.com/......Fcrawler_play.png [upload_date] => 2019-11-19 06:27:37 [video_id] => 374131624 [uri] => /videos/374131624 [embera_using_fake_response] => 0 [embera_provider_name] => Vimeo ) [https://www.flickr.com/photos/bees/8597283706/in/photostream] => Array ( [type] => photo [flickr_type] => photo [title] => Durumu [author_name] => bees [author_url] => https://www.flickr.com/photos/bees/ [width] => 1024 [height] => 723 [url] => https://live.staticflickr.com/8385/8597283706_7b51ea50b1_b.jpg [web_page] => https://www.flickr.com/photos/bees/8597283706/ [thumbnail_url] => https://live.staticflickr.com/8385/8597283706_7b51ea50b1_q.jpg [thumbnail_width] => 150 [thumbnail_height] => 150 [web_page_short_url] => https://flic.kr/p/e6HjVq [license] => All Rights Reserved [license_id] => 0 [html] => ......... [version] => 1.0 [cache_age] => 3600 [provider_name] => Flickr [provider_url] => https://www.flickr.com/ [embera_using_fake_response] => 0 [embera_provider_name] => Flickr [html_alternative] => ........ ) )
The response data depends on the provider, each of them returns information about the consulted
media, however this library always tries to provide an embeddable html key that can be used to
embed the information on a html document.
This library has fake responses / Offline support which is a way of getting the html embeddable code without the need of querying the oembed provider. It also has caching support, provider collections, responsive embeds and many other features. You can find out more by reading the documentation below.
Documentation
- Usage/Configuration instructions
- Supported providers
- Using provider collections
- Using fake Responses
- Using responsive embeds
- Enabling cache
- Advanced Usage
Migrating from version >= 1.9.x
The folder structure has changed, the library is now in the src folder and
you can find an autoloader there if you are not using composer.
The configuration array has changed in order to make it simpler. Take a look at the Usage/Configuration instructions to update it.
The other major change is that the inspectUrlInfo() method is now called getUrlData().
The HtmlFormatter class does not exist anymore since the library allows now other type
of templating.
Updating should be fairly easy, check the documentation.
Submitting bugs and feature requests
Bugs and feature request are tracked on GitHub
Author
Michael Pratt - yo@michael-pratt.com - http://www.michael-pratt.com See also the list of contributors which participated in this project.
If you like this library, it has been useful to you and want to support me, you can do it via paypal.
License
Embera is licensed under the MIT License - see the LICENSE file for details
mpratt/embera 适用场景与选型建议
mpratt/embera 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6M 次下载、GitHub Stars 达 353, 最近一次更新时间为 2013 年 05 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「oembed」 「twitter」 「youtube」 「vimeo」 「instagram」 「embed」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mpratt/embera 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mpratt/embera 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mpratt/embera 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Handles basic OAuth/OAuth2 authentication along with classes for common services
Bundle with a way of defining oEmbed providers, and rendering oEmbed in templates.
Simple Twitter API wrapper
Get detailed info for any URL on the internet! Scraper for HTML, OpenGraph, Schema data
Easy to use SDK with grabber for multiple platforms at once like YouTube, Dailymotion, Facebook and more.
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
统计信息
- 总下载量: 6M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 363
- 点击次数: 41
- 依赖项目数: 21
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-05-16