-
-
Save anjan011/1fcecdc236594e6d700f to your computer and use it in GitHub Desktop.
<?php | |
/** | |
* Get Vimeo video id from url | |
* | |
* Supported url formats - | |
* | |
* https://vimeo.com/11111111 | |
* http://vimeo.com/11111111 | |
* https://www.vimeo.com/11111111 | |
* http://www.vimeo.com/11111111 | |
* https://vimeo.com/channels/11111111 | |
* http://vimeo.com/channels/11111111 | |
* https://vimeo.com/groups/name/videos/11111111 | |
* http://vimeo.com/groups/name/videos/11111111 | |
* https://vimeo.com/album/2222222/video/11111111 | |
* http://vimeo.com/album/2222222/video/11111111 | |
* https://vimeo.com/11111111?param=test | |
* http://vimeo.com/11111111?param=test | |
* | |
* @param string $url The URL | |
* | |
* @return string the video id extracted from url | |
*/ | |
function getVimeoVideoIdFromUrl($url = '') { | |
$regs = array(); | |
$id = ''; | |
if (preg_match('%^https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\?)(?:[?]?.*)$%im', $url, $regs)) { | |
$id = $regs[3]; | |
} | |
return $id; | |
} |
Nice THANKS!
Nice!
But not support everything of the Vimeo link.
This link not working: https://vimeo.com/277465256#t=60s
You can use this reg to achieve:
%^https?:\/\/(?:www\.|player\.)?vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/([^\/]*)\/videos\/|album\/(\d+)\/video\/|video\/|)(\d+)(?:$|\/|\#?)(?:[?]?.*)$%im
Nice!
But not support everything of the Vimeo link.
This link not working: https://vimeo.com/277465256#t=60s
Hi
I have a different Vimeo URL (https://vimeo.com/355415017/1b3271f41f). What is the id of this URL?
how to get video details from id?
how to get video details from id?
You can only do that with their API: https://developer.vimeo.com/api/reference/videos#get_video
Pretty straight forward though.
how to get video details from id?
check this
https://stackoverflow.com/questions/10488943/easy-way-to-get-vimeo-id-from-a-vimeo-url
Nice! thanks.