Skip to content

Instantly share code, notes, and snippets.

@vctrfrnndz
vctrfrnndz / gist:5105351.php
Last active December 14, 2015 15:08
Youtube id regular expression (getting url from Wordpress meta tag)
$video_url = get_post_meta( get_the_ID(), 'mb_youtube_url', true );
// Parse video ID from given url
if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $video_url, $match)) {
$video_id = $match[1]; // Return video ID
}
@vctrfrnndz
vctrfrnndz / gist:4642918.php
Last active December 11, 2015 18:38
Obtain a list of videos from a Vimeo account using PHP
<?php
// Account to get the videos from
$username = 'user6002596';
// Do request to Vimeo API
$request = 'http://vimeo.com/api/v2/'. $username .'/videos.xml';
// Parse into SimpleXML object
$vimeo = simplexml_load_file($request);