Youtube 채널의 특정 재생 목록에서 비디오 정보를 가져 오는 PHP 루프가 있지만 비공개 비디오가 발견되면 중단됩니다. 그것은 치명적인 오류를 제공합니다 :youtube api error
Warning: main() [function.main]: Node no longer exists in F:\xampp\htdocs\youtube\index.php on line 30
Warning: main() [function.main]: Node no longer exists in F:\xampp\htdocs\youtube\index.php on line 30
Fatal error: Call to a member function attributes() on a non-object in F:\xampp\htdocs\youtube\index.php on line 35
코드는 제발 도와주세요
<body>
<div id="mainPlayer" width="425" height="344">
</div>
</div>
<div id="mainPlaylist" class="grid_6 omega">
<h3 class="title">Legal Feed with Kate Wheeler</h3>
<ul id="playlists">
<?php
// Loop through each video in each playlist
// read feed into SimpleXML object
// *Moved into header to load main Video as well
$playlistFeedURL = 'http://gdata.youtube.com/feeds/api/playlists/6549D4CA7BB99B16?v=2';
$sxml = simplexml_load_file($playlistFeedURL);
// iterate over entries in feed
foreach ($sxml->entry as $entry) {
// get nodes in media: namespace for media information
$media = $entry->children('http://search.yahoo.com/mrss/');
// get video player URL
$attrs = $media->group->player->attributes();
$watch = $attrs['url'];
// get video thumbnail
$attrs = $media->group->thumbnail[0]->attributes();
$thumbnail = $attrs['url'];
// get <yt:duration> node for video length
$yt = $media->children('http://gdata.youtube.com/schemas/2007');
$attrs = $yt->duration->attributes();
$length = $attrs['seconds'];
//get <yt:videoId> node for Video ID
$yt = $media->children('http://gdata.youtube.com/schemas/2007');
$playlistVideoID = $yt->videoid;
// get <yt:stats> node for viewer statistics
$yt = $entry->children('http://gdata.youtube.com/schemas/2007');
$attrs = $yt->statistics->attributes();
$viewCount = $attrs['viewCount'];
// get <gd:rating> node for video ratings
$gd = $entry->children('http://schemas.google.com/g/2005');
if ($gd->rating) {
$attrs = $gd->rating->attributes();
$rating = $attrs['average'];
} else {
$rating = 0;
}
?>
<div class="item">
<span class="thumbnail left" rel="<?php echo $entry->id; ?>">
<a href="<?php echo $watch; ?>" rel="<?php echo $playlistVideoID; ?>" onclick="_run();"><img src="<?php echo $thumbnail;?>" /></a>
</span>
<a href="<?php echo $watch; ?>" rel="<?php echo $playlistVideoID; ?>" onclick="_run();"><?php echo $media->group->title; ?></a>
<span class="attr">Duration:</span> <?php printf('%0.2f', $length/60); ?> min.
<div class="clear"></div>
</div>
<?php
}
?>
</ul>
</body>
이하입니다. 미리 감사드립니다.
사람들이 당신을 도울 수 있도록 관련 코드 부분을 게시하십시오. 또는 오류 메시지를 작동 및 게시 할 수있는 무언가를 시도하십시오. – Ali
피드가 특정 요소를 포함하지 않는 것이 정상입니다 (예 : 업 로더가 평점/좋아요/싫어요를 사용 중지하면 등급 입력란이 누락됩니다. 속성을 읽기 전에 노드가 있는지 확인하십시오. –