【发布时间】:2017-06-11 17:54:22
【问题描述】:
我有一个托管客户视频的网站。在网站上,文件通过 m3u8 链接从外部加载。
客户现在希望在 Roku 频道上播放这些视频。
如果我只是使用站点中的 m3u8 链接,则会出现错误,因为生成的 url 是通过 cookie 发送的,因此客户端必须单击该链接才能为它们生成新代码。
如果可能的话(我在这里没有看到)我希望抓取 html 页面,然后通过 Roku 网站上的 PHP 脚本返回链接。
我知道如何使用纯 php 获取标题等,但在返回 m3u8 链接时遇到问题..
我确实有代码表明我不是在寻找讲义,而是在尝试。
这是我用来获取标题名称的例子。
注意:我想知道是否有可能有一个 php 自动填充每个 url 的 html 页面,所以我不必为每个预先输入 url 的视频使用不同的 php。
<?php
$html = file_get_contents('http://example.com'); //get the html returned from the following url
$movie_doc = new DOMDocument();
libxml_use_internal_errors(TRUE); //disable libxml errors
if(!empty($html)){ //if any html is actually returned
$movie_doc->loadHTML($html);
libxml_clear_errors(); //remove errors for yucky html
$movie_xpath = new DOMXPath($movie_doc);
//get all the titles
$movie_row = $movie_xpath->query('//title');
if($movie_row->length > 0){
foreach($movie_row as $row){
echo $row->nodeValue . "<br/>";
}
}
}
?>
【问题讨论】:
-
你能告诉我们一个实际的网址吗?
-
这在 Roku 方面也可能可行,roUrlTransfer 支持自定义标头和 cookie