php-video-url-parser
php-video-url-parser copied to clipboard
Title / Description?
I see in the readme that the parser can obtain titles and descriptions, however I don't see anything related to this in the code? How can this be achieved?
function getVimeoMeta($videoId)
{
try {
$hash = json_decode(file_get_contents("http://vimeo.com/api/v2/video/{$videoId}.json"));
if (is_array($hash) and array_key_exists(0, $hash)) {
return $hash[0];
}
} catch (\Exception $e) {
return false;
}
return false;
}
function getYoutubeMeta($videoId)
{
try {
$url = 'https://www.googleapis.com/youtube/v3/videos?part=snippet&id=' . $videoId . '&key=yourcode';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
$decoded = json_decode($data, true);
foreach ($decoded['items'] as $items) {
return $items['snippet'];
}
} catch (\Exception $e) {
return false;
}
return false;
}