This is my youtube tube URL which is coming from facebook Id. I have fetch this url using FQL Query in facebook in Zend Framework
This is my url = "http://www.youtube.com/attribution_link?a=AbE6fYtNaa4&u=%2Fwatch%3Fv%3DNbyHNASFi6U%26feature%3Dshare"
Now I need to fetch its ID so that I can pass it to this code so that i can generate its vidoe details.
function listYoutubeVideo($id) {
$video = array();
try {
$yt = new Zend_Gdata_YouTube();
$videoEntry = $yt->getVideoEntry($id);
$videoEntry = $yt->getQueryUrl($id);
$videoThumbnails = $videoEntry->getVideoThumbnails();
$video = array(
'thumbnail' => $videoThumbnails[0]['url'],
'title' => $videoEntry->getVideoTitle(),
'description' => $videoEntry->getVideoDescription(),
'tags' => implode(', ', $videoEntry->getVideoTags()),
'url' => $videoEntry->getVideoWatchPageUrl(),
'flash' => $videoEntry->getFlashPlayerUrl(),
'dura' => $videoEntry->getVideoDuration(),
'id' => $videoEntry->getVideoId()
);
} catch (Exception $e) {
echo $e->getMessage();
exit();
}
return $video;
}
So I just need to find its youtube ID from youtube URL in Zend Framework. Plz provide me solutions. Is there any method exist in "Zend_Gdata_YouTube"
class from where i can get its ID form passing its youtube URL
You have unique video ID. In your case (https://www.youtube.com/watch?v=NbyHNASFi6U&feature=share) ID equals NbyHNASFi6U.
$url = 'http://www.youtube.com/attribution_link?a=AbE6fYtNaa4&u=%2Fwatch%3Fv%3DNbyHNASFi6U%26feature%3Dshare';
$url = urldecode($url);
$query_string = end(explode('?',$url));
parse_str($query_string);
$videoID = $v;
print $videoID;
// OUTPUT
NbyHNASFi6U
The video watch page URL always has this format:
http://www.youtube.com/watch?v=XXXXXXXXXXX
where XXXXXXXXXXX is a unique video ID consisting of 11 letters and numbers (and, if memory serves, hyphens and underscores).