获取 YouTube 视频的标题
我正在使用以下代码来获取一些 YouTube 视频的标题,该视频以前运行良好,但自最近几天以来我收到了一些错误/警告,
$entry = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/' . $key);
return ($entry) ? ucwords(strtolower($entry->children('http://search.yahoo.com/mrss/')->group->title)) : false;
警告:simplexml_load_file() [function.simplexml-load-file]:http ://gdata.youtube.com/feeds/api/videos/jIP4xI9C8us:1:解析器错误:文档为空/home/public_html/panel/index.php 第 214 行
警告:simplexml_load_file() [function.simplexml-load-file]:位于 /home/public_html/panel/index.php 第 214 行
警告:simplexml_load_file() [function.simplexml-load-file]: ^ 在 /home/public_html/panel/index.php 第 214 行
警告:simplexml_load_file() [function.simplexml-load-file]:http ://gdata.youtube.com/feeds/api/videos/jIP4xI9C8us:1:解析器错误:需要开始标记,“<”在 /home/public_html/panel/index.php 第 214 行中找不到
警告:simplexml_load_file() [function.simplexml-load-file]:位于 /home/public_html/panel/index.php 第 214 行
警告:simplexml_load_file() [function.simplexml-load-file]: ^ 在 /home/public_html/panel/index.php 第 214 行
I am using following code to get title of some YouTube video, which was working fine previously but I am getting some error/warnings since last few days,
$entry = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/' . $key);
return ($entry) ? ucwords(strtolower($entry->children('http://search.yahoo.com/mrss/')->group->title)) : false;
Warning: simplexml_load_file() [function.simplexml-load-file]: http://gdata.youtube.com/feeds/api/videos/jIP4xI9C8us:1: parser error : Document is empty in /home/public_html/panel/index.php on line 214
Warning: simplexml_load_file() [function.simplexml-load-file]: in /home/public_html/panel/index.php on line 214
Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home/public_html/panel/index.php on line 214
Warning: simplexml_load_file() [function.simplexml-load-file]: http://gdata.youtube.com/feeds/api/videos/jIP4xI9C8us:1: parser error : Start tag expected, '<' not found in /home/public_html/panel/index.php on line 214
Warning: simplexml_load_file() [function.simplexml-load-file]: in /home/public_html/panel/index.php on line 214
Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in /home/public_html/panel/index.php on line 214
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是我的方法。
使用 Youtube Data API v3.0
google-api-php-client 库
here's my way.
use Youtube Data API v3.0
google-api-php-client library
您可以尝试用以下函数替换对
simplexml_load_file
的调用,看看是否存在相同的问题?听起来您的主机可能更改了一些 PHP 安全设置。PS 当我从您的 URL 中删除
:1
时,它会在浏览器中加载该文件。Can you try replacing your call to
simplexml_load_file
with the following function and see if it has the same issue? Sounds like your host may have changed some PHP security settings.P.S. When I remove
:1
from your URL, it loads the file up when going there in a browser.我的方法:
函数
main
My way:
function
main