1 回答

TA貢獻1815條經(jīng)驗 獲得超13個贊
如果標題代碼不是 200,只需打印視頻 ID?
while ($row = $result->fetch_assoc()) {
$headers = get_headers('http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v='.$row["src_id"].'');
if (!strpos($headers[0], '200')) {
echo "Video ID: ".$row['src']." is invalid\n";
}
}
可能還想研究一種更好的獲取響應標頭的方法,該方法可能并非對所有情況都 100% 準確。我建議使用類似的東西
while ($row = $result->fetch_assoc()) {
$headers = get_headers('http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v='.$row["src_id"].'');
if (substr($headers[0], 9, 3) != 200) {
echo "Video ID: ".$row['src']." is invalid\n";
}
}
- 1 回答
- 0 關(guān)注
- 135 瀏覽
添加回答
舉報