php-video-url-parser icon indicating copy to clipboard operation
php-video-url-parser copied to clipboard

Title / Description?

Open christianmagill opened this issue 5 years ago • 1 comments

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?

christianmagill avatar Jan 20 '20 18:01 christianmagill

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;
}

tamert avatar Jun 14 '21 14:06 tamert