ricardofiorani / oembed
OEmbed是一个PHP库,帮助您从支持OEmbed的提供商中检索数据。
v1.2.0
2022-06-01 21:57 UTC
Requires
- php: ^7.4 || ^8.0 || ^8.1
- ext-json: *
- php-http/discovery: ^1.7
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- http-interop/http-factory-guzzle: ^1.0
- php-http/guzzle6-adapter: ^2
- phpstan/phpstan: ^0.12.82
- phpunit/phpunit: ^8.4
- squizlabs/php_codesniffer: ^3.5
This package is auto-updated.
Last update: 2024-09-14 00:34:32 UTC
README
OEmbed是一个PHP库,帮助您从支持OEmbed的提供商中检索数据。
该库旨在成为ricardofiorani/php-video-url-parser
的继任者。
安装
使用以下命令安装最新版本:
$ composer require ricardofiorani/oembed
需求
- PHP 7.4
- PSR-18实现
RequestFactory
和UriFactory
的PSR-17实现
基本用法
<?php declare(strict_types=1); use Your\PSR7Implementation\Uri; use RicardoFiorani\OEmbed\OEmbed; require __DIR__ . '/vendor/autoload.php'; $service = new OEmbed(); $uri = new Uri('https://www.dailymotion.com/video/x804zfb?playlist=x6ymns'); $result = $service->get( $uri, 480, 300, ['omitscript' => true] ); echo (string)$result; //will render the HTML (in case of "video" or "rich") or URL (in case of "photo")
支持并测试过的服务
- Dailymotion
- Deviantart.com
- Facebook*
- Gfycat
- Giphy
- Instagram*
- Kickstarter
- Me.me
- Soundcloud
- Spotify
- Twitch
- Vimeo
- Youtube
*Facebook和Instagram需要认证
请参阅https://developers.facebook.com/docs/instagram/oembed
同时请参阅本文档底部的示例
支持但未测试过的服务
- 23HQ
- Abraia
- Adways
- Alpha App Net
- Altru
- amCharts Live Editor
- Animatron
- Animoto
- Apester
- ArcGIS StoryMaps
- Archivos
- Audioboom
- AudioClip
- Audiomack
- AudioSnaps
- Avocode
- AxiomNinja
- Backtracks
- Beautiful.AI
- Blackfire.io
- Blogcast
- Box Office Buz
- BrioVR
- Buttondown
- Byzart Project
- Cacoo
- Carbon Health
- CatBoat
- Ceros
- ChartBlocks
- chirbit.com
- CircuitLab
- Clipland
- Clyp
- CoCo Corp
- CodeHS
- Codepen
- Codepoints
- CodeSandbox
- CollegeHumor
- Commaful
- Coub
- Crowd Ranking
- Cyrano Systems
- Daily Mile
- Datawrapper
- Deseret News
- Didacte
- Digiteka
- Dipity
- DocDroid
- Dotsub
- DTube
- edocr
- eduMedia
- EgliseInfo
- Embed Articles
- Embedery
- Embedly
- Ethfiddle
- Eyrie
- Fader
- Faithlife TV
- Firework
- FITE
- Flat
- Flickr
- Flourish
- Fontself
- FOX SPORTS Australia
- FrameBuzz
- FunnyOrDie
- Geograph Britain and Ireland
- Geograph Channel Islands
- Geograph Germany
- Getty Images
- Gifnote
- GloriaTV
- GT Channel
- Gyazo
- hearthis.at
- hihaho
- Homey
- HuffDuffer
- Hulu
- iFixit
- IFTTT
- iHeartRadio
- Indaco
- Infogram
- Infoveave
- Injurymap
- Inoreader
- inphood
- iSnare Articles
- Issuu
- ivlismusic
- Jovian
- KakaoTv
- Kidoju
- Kirim.Email
- Kit
- Kitchenbowl
- Knacki
- Knowledge Pad
- LearningApps.org
- Lille.Pod
- Livestream
- Ludus
- MathEmbed
- Matterport
- MediaLab
- Medienarchiv der Künste - Zürcher Hochschule der Künste
- Mermaid Ink
- Microlink
- Microsoft Stream
- MixCloud
- Moby Picture
- Modelo
- MorphCast
- Music Box Maniacs
- myBeweeg
- Namchey
- nanoo.tv
- Nasjonalbiblioteket
- 自然图谱
- nfb.ca
- Odds.com.au
- odesli(原名Songlink)
- 官方FM
- Omniscope
- 在Aol上
- Ora TV
- Orbitvu
- Oumy
- Outplayed.tv
- Overflow
- OZ
- Padlet
- Pastery
- PingVP
- Pinpoll
- Pixdor
- Podbean
- Polaris Share
- Poll Daddy
- Port
- Portfolium
- posiXion
- Qualifio
- Quiz.biz
- Quizz.biz
- RadioPublic
- RapidEngage
- ReleaseWire
- Replit
- RepubHub
- ReverbNation
- RiffReporter
- Roomshare
- RoosterTeeth
- Rumble
- Runkit
- Sapo Videos
- Screen9
- Screencast.com
- Screenr
- ScribbleMaps
- Scribd
- SendtoNews
- ShortNote
- Shoudio
- 展示路线,可操作的位置信息
- Simplecast
- Sizzle
- Sketchfab
- SlideShare
- SmashNotes
- SmugMug
- SocialExplorer
- Soundsgood
- SpeakerDeck
- Spotful
- Spreaker
- 斯坦福数字存储库
- Streamable
- StreamOneCloud
- Sutori
- Sway
- TED
- 纽约时报
- 他们这么说
- TickCounter
- TikTok
- Toornament
- Topy
- Tuxx
- tvcf
- TypeCast
- Typlog
- Ubideo
- 剑桥大学地图
- UnivParis1.Pod
- UOL
- Ustream
- uStudio, Inc.
- Utposts
- Uttles
- VeeR VR
- Verse
- VEVO
- VideoJug
- Vidlit
- Vidmizer
- Vidyard
- Viously
- Viziosphere
- Vizydrop
- Vlipsy
- VLIVE
- Vlurb
- VoxSnap
- Wave.video
- wecandeo
- Wiredrive
- Wistia, Inc.
- wizer.me
- Wokwi
- Wootled
- WordPress.com
- Xpression
- 是的,我知道IT!
- YFrog
- Zeplin
- ZingSoft
- ZnipeTV
- 可缩放的
- 以及所有未提到的服务均可在https://oembed.com/providers.json上找到
当前支持的PHP版本
- PHP 7.4 || PHP 8.0 || PHP 8.1
Facebook和Instagram需要认证
是的,我知道,创建FB应用并生成令牌真的很糟糕。
无论如何,有两种方法(可能更多,但现在我只能想到两种)可以使这个库与FB和IG协同工作。
方法1
您创建一个自定义的HTTP客户端(实现 \Psr\Http\Client\ClientInterface
)并指导它按照Facebook指南检索令牌。
方法2
更简单的方法,您只需将应用程序ID和密钥作为额外参数发送到端点即可。
$service = new OEmbed(); $uri = new Uri('https://#/FacebookDeutschland/videos/2403439749688130/'); $result = $service->get( $uri, 480, 300, ['access_token' => `{$appId}|{$appSecret}`] );