1

我正在使用 SimplePie 解析我们的教堂 RSS 提要,其中包含每周的布道,包括音频和视频。我能够获得标题和 mp3 链接,但很难获得 youtube 链接。以下是包含 youtube 视频的 XML 提要中的示例。

它正在使用[CDATA]

我正在使用$item->get_content(),但它似乎不包含下面的任何标签数据。提要的网址是http://lakeforest.org/feed。当我在浏览器中打开这个 url 时,我可以看到嵌入的 youtube 视频。

任何帮助将不胜感激。

注意:-我评论了下面的 html 仅用于显示

<!--
<description><![CDATA[Huntersville Campus Mike Moses, Lead Pastor Series Discussion Questions: SHAPE, Part 2 Spiritual Gifts Inventory VIDEO AUDIO]]></description>
                <content:encoded><![CDATA[<h3>Huntersville Campus</h3>
<p>Mike Moses, Lead Pastor<br />
<a href="http://lakeforest.org/wp-content/uploads/2013/01/SDQ_SHAPEPt2.pdf">Series Discussion Questions: SHAPE, Part 2</a><br />
<a href="http://www.churchgrowth.org/cgi-cg/gifts.cgi?intro=1 <http://www.churchgrowth.org/cgi-cg/gifts.cgi?intro=1" target="_blank">Spiritual Gifts Inventory</a></p>
<h4>VIDEO</h4>
<p><iframe width="420" height="315" src="http://www.youtube.com/embed/4Uv8U8c6isg" frameborder="0" allowfullscreen></iframe></p>
<h4>AUDIO</h4>
<img src="http://feeds.feedburner.com/~r/LakeForest/~4/qMoLVpI1tGI" height="1" width="1"/>]]>  -->
4

2 回答 2

1

SimplePie默认会去除embed,objectiframe标签,因为它们可能很危险。

如果您想要恢复视频,您应该忽略它们,但要小心源 URL,因为它可能是一个安全问题。

$feed = new SimplePie();
$feed->set_feed_url('http://simplepie.org/blog/feed/');

// Remove these tags from the list
$strip_htmltags = $feed->strip_htmltags;
array_splice($strip_htmltags, array_search('object', $strip_htmltags), 1);
array_splice($strip_htmltags, array_search('param', $strip_htmltags), 1);
array_splice($strip_htmltags, array_search('embed', $strip_htmltags), 1);
array_splice($strip_htmltags, array_search('iframe', $strip_htmltags), 1);

$feed->strip_htmltags($strip_htmltags);

资源

于 2013-10-16T09:28:28.210 回答
0

我刚刚注意到您的提要 URL,这不是我所期待的,我期待的是这样的:

http://gdata.youtube.com/feeds/base/videos?q=painting+miniatures+tutorial&orderby=published&client=ytapi-youtube-search&v=2

这是来自 YouTube 的搜索结果提要,我在此处将其传递给 SimplePie 。此外,您声明 $item 的其余 PHP 代码也会很有用。今晚我回答了一个类似的问题,基本上这些年来 YouTube 已经改变了他们的 API 和提要,即使你能找到它工作的旧示例,你也可能必须更新到他们的 API/提要的更新版本。

SimplePie 可以处理一些(如果不是全部)YouTube 提要,但不能保证 Google (YouTube) 会为您提供缩略图以及他们在 YouTube.com 上拥有的所有元数据。API 通常通过 API 提供其数据库中包含的数据子集,他们希望人们访问他们的网站,以便向他们展示广告并更好地跟踪它们。

也许不是您想要的答案,但没有更多信息,这是我能做的最好的。

如果您想深入研究提要并获取视频 URL,然后为它创建一个播放器,这是非常重要的。您必须使用 simple_html_dom 之类的东西,然后您需要创建格式正确的 iframe 或 javascript 调用来创建浏览器内播放器。SimplePie 没有 get_contents()->video

于 2013-03-12T03:19:18.560 回答