gpt4 book ai didi

php - 如何检查YouTube是否存在视频ID

转载 作者:行者123 更新时间:2023-12-03 05:21:12 25 4
gpt4 key购买 nike

我想做的就是检查用户输入的视频是否确实存在,我进行了很多搜索,发现这是ReRetrieving_Video_Entry,但看起来好像已弃用,因此如何使用Google APIs Client Library for PHP来检查视频是否存在或不?

最佳答案

我使用这种技术修复了它,不需要任何API的使用:

   $headers = get_headers('https://www.youtube.com/oembed?format=json&url=http://www.youtube.com/watch?v=' . $key);

if(is_array($headers) ? preg_match('/^HTTP\\/\\d+\\.\\d+\\s+2\\d\\d\\s+.*$/',$headers[0]) : false){
// video exists

} else {
// video does not exist
echo json_encode(array('Error','There is no video with that Id!'));
}

关于php - 如何检查YouTube是否存在视频ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32855585/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com