-
-
Save smahi/f79b77b69bf55a138bf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function youtube_title() { | |
$id = 'YOUTUBE_ID'; | |
// returns a single line of XML that contains the video title. Not a giant request. Use '@' to suppress errors. | |
$videoTitle = @file_get_contents("http://gdata.youtube.com/feeds/api/videos/{$id}?v=2&fields=title"); | |
// look for that title tag and get the insides | |
preg_match("/<title>(.+?)<\/title>/is", $videoTitle, $titleOfVideo); | |
return $titleOfVideo[1]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment