Youtube の動画情報を取得する方法をいろいろと検索しましたが、いくつかの良い結果が得られましたが、まだ 1 つの問題があります。一部の動画では、私のコードが評価を取得しません。
私のコード:
$feedURL = 'http://gdata.youtube.com/feeds/api/videos/' . $link;
$entry = simplexml_load_file($feedURL);
$video = parseVideoEntry($entry);
$rating = $video->rating;
$ratingf = (float)$rating*20;
function parseVideoEntry($entry) {
$obj= new stdClass;
$gd = $entry->children('http://schemas.google.com/g/2005');
if ($gd->rating) {
$attrs = $gd->rating->attributes();
$obj->rating = $attrs['average'];
} else {
$obj->rating = 0;
}
return $obj;
}
そのため、一部のビデオでこの 0 を取得していますが、その理由を見つけることができません。動画によって違いはありますか?