来自youtube的警告simplexml_load_file解析器错误

时间:2014-01-19 06:02:35

标签: xml-parsing youtube youtube-api simplexml http-status-code-403

当我在youtube脚本中搜索视频时,偶尔会出现此错误,有时它只是有效,但问题再次出现。有人可以帮我解决这个问题吗?

错误讯息:

Warning: simplexml_load_file(http://gdata.youtube.com/feeds/api/videos?vq=music&orderby=relevance&max-results=10&start-index=201&lr=en): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /home/website/public_html/search.php on line 119 

Warning: simplexml_load_file(): I/O warning : failed to load external entity "http://gdata.youtube.com/feeds/api/videos?vq=music&orderby=relevance&max-results=10&start-index=201&lr=en" in /home/website/public_html/search.php on line 119

Fatal error: Call to a member function children() on a non-object in /home/website/public_html/search.php on line 122 

第119行:

$sxml = simplexml_load_file($feedURL);

第122行:

$counts = $sxml->children('http://a9.com/-/spec/opensearchrss/1.0/');

1 个答案:

答案 0 :(得分:0)

Youtube限制了您的自动请求,这就是“偶尔”脚本不起作用的原因......请改用youtube api