项目作者: baraja-core

项目描述 :
Parse video token from user string or URL.
高级语言: PHP
项目地址: git://github.com/baraja-core/video-token.git
创建时间: 2021-07-12T12:02:04Z
项目社区:https://github.com/baraja-core/video-token

开源协议:MIT License

下载


Video token

Parse video token from user string or URL.

How to use

Detect token from URL:

  1. $token = new \Baraja\VideoToken\VideoToken(
  2. 'https://www.youtube.com/watch?v=_Gi_LQ0a8EA'
  3. );
  4. // or
  5. $token = new \Baraja\VideoToken\VideoToken('_Gi_LQ0a8EA', 'youtube');
  6. echo $token->getToken(); // _Gi_LQ0a8EA
  7. echo $token->getProvider(); // youtube
  8. echo $token->getThumbnailUrl(); // https://img.youtube.com/vi/_Gi_LQ0a8EA/maxresdefault.jpg
  9. echo $token->getUrl(); // https://www.youtube.com/embed/_Gi_LQ0a8EA?rel=0

The input can be a URL from one of the supported video platforms, or a token and provider. The validity of the passed token will be automatically verified.

The operation of getting a preview image can be performance intensive, so always cache the result of the call.