PHP DOM 获取空白页的文本


PHP DOM get text of blank page

我得到YouTube视频,这段代码是有效的。

<?php   
$feedURL = "http://gdata.youtube.com/feeds/api/users/".$user."/uploads?max-results=20";
    $sxml = simplexml_load_file($feedURL);
    $i=0;
    foreach ($sxml->entry as $entry) {
      $media = $entry->children('media', true);
      $watch = (string)$media->group->player->attributes()->url;   
      $url = clear($watch); 
//..............................
?>

但是用户被禁止YouTube得到空白页

User account suspended

http://gdata.youtube.com/feeds/api/users/MonsterJamVEVO/uploads?max-results=5

如何获取文本(用户帐户已暂停)因为是没有任何标签。谢谢。

响应标头指示问题:

HTTP/1.1 403 禁止

因此,您必须检查这些错误:

$feedURL = "http://gdata.youtube.com/feeds/api/users/".$user."/uploads?max-results=20";
if (($contents = @file_get_contents($feedURL)) === false) {
    echo "$feedURL could not be loaded'n";
} else {
    $sxml = simplexml_load_string($contents);
    // rest of your code
}