Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP获取并返回媒体url(m3u8)_Php_Html_Dom_Curl_Roku - Fatal编程技术网

使用PHP获取并返回媒体url(m3u8)

使用PHP获取并返回媒体url(m3u8),php,html,dom,curl,roku,Php,Html,Dom,Curl,Roku,我有一个网站,从客户那里托管视频。在网站上,通过m3u8链接从外部加载文件 客户现在希望在Roku频道播放这些视频 如果我只是从站点使用m3u8链接,它会给出一个错误,因为生成的url是与cookie一起发送的,因此客户端必须单击该链接为它们生成新代码 我想如果可能的话(我没有看到这一点),是刮的html页面,只是通过PHP脚本返回从Roku网站的链接 我知道如何使用纯php获取标题等,但返回m3u8链接时遇到问题 我确实有代码显示我不是在寻找讲义,而是在尝试 这就是我用来获取标题名的例子 注意

我有一个网站,从客户那里托管视频。在网站上,通过m3u8链接从外部加载文件

客户现在希望在Roku频道播放这些视频

如果我只是从站点使用m3u8链接,它会给出一个错误,因为生成的url是与cookie一起发送的,因此客户端必须单击该链接为它们生成新代码

我想如果可能的话(我没有看到这一点),是刮的html页面,只是通过PHP脚本返回从Roku网站的链接

我知道如何使用纯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/>";
        }
    }
}
?>

有一种简单的方法可以实现这一点,其中包括使用正则表达式

在本例中,假设视频M3u8文件位于:

您可以将XML中的视频URL源指向PHP文件


现在,如果你想使用一个URL,你可以在它的末尾附加一个URL链接,它可能看起来像这样,你可以使用一个地址作为位于



您能给我们显示一个实际的url吗?这在Roku方面也可能是可行的,roUrlTransfer支持自定义标题和cookie
<?php
$html = file_get_contents("http://example.com/theVideoPage");

preg_match_all(
    '/(http.*m3u8)/',

    $html,
    $posts, // will contain the article data
    PREG_SET_ORDER // formats data into an array of posts
);

foreach ($posts as $post) {
    $link = $post[0];

header("Location: $link");
}
?>
<?php
$id = $_GET['id'];
$html = file_get_contents("http://example.com".$id);

preg_match_all(
    '/(http.*m3u8)/',

    $html,
    $things, // will contain the article data
    PREG_SET_ORDER // formats data into an array of posts
);

foreach ($things as $thing) {
    $link = $thing[1];

// clear out the output buffer
while (ob_get_status())
{
    ob_end_clean();
}

// no redirect
header("Location: $link");

}
?>