我想在我的網站獲取文本此信息YouTube的信息:獲取與PHP
http://gdata.youtube.com/feeds/api/videos/IyBvgi4ZlbM
時未找到該視頻。
我該如何寫入代碼?
我不明白這裏:
https://developers.google.com/youtube/2.0/developers_guide_php?csw=1
謝謝!
我想在我的網站獲取文本此信息YouTube的信息:獲取與PHP
http://gdata.youtube.com/feeds/api/videos/IyBvgi4ZlbM
時未找到該視頻。
我該如何寫入代碼?
我不明白這裏:
https://developers.google.com/youtube/2.0/developers_guide_php?csw=1
謝謝!
你可以嘗試檢查視頻是否可用與headers
:
$headers = get_headers("http://gdata.youtube.com/feeds/api/videos/".$row['youtube']);
if (!strpos($headers[0], '200'))
{
echo "Video is not found";
}
好...我需要添加這個,但有錯誤「$ headers = get_headers('http://gdata.youtube.com/feeds/api/videos/'<?echo $ row [ 'youtube'];?>');「 – user3806434
得到了...警告:get_headers():該函數只能用於/home/swapes/domains/swapes.com/public_html/cppx/page_youtube.php中的URL第125行視頻未找到 – user3806434
您錯過了'http://':)試試這行'$ headers = get_headers(「http://gdata.youtube.com/feeds/api/videos/」。$ row ['youtube ']);' – Bora
試試這個;)
<?php
$headers = get_headers('http://gdata.youtube.com/feeds/api/videos/IyBvgi4ZlbM');
$is_ok = substr($headers[0], 9, 3) == 200;
if($is_ok){
echo 'Video is OK :)';
}
else{
echo 'Something is wrong :(';
}
我得到的迴應http://gdata.youtube.com/feeds/ API /視頻/ 0KSOMA3QBU0。您的視頻ID無效http://www.youtube.com/watch?v=IyBvgi4ZlbM – Bora
是無效的...我想這個文本「視頻未找到」,以查看在我的網站中的所有無效視頻。 – user3806434
可能的重複[如何檢查視頻是否存在於YouTube上,使用PHP?](http://stackoverflow.com/questions/1383073/how-do-i-check-if-a-video-exists-on -youtube-using-php) –