我想从网站上获取身份验证令牌
http://0--0.gq/Jio/Bittu_Ghosh_22.php
然后想要重定向到该网站(标题 用户代理Mozilla / 5.0(Windows NT 6.1; Win64; x64; rv:47.0)Gecko / 20100101 Firefox / 47.0 < /强>)
http://test.m3u8 来自0--0网站的验证码来源;
与http://test.m3u8?jct=UCS4RJSHD5jo8arL58VzIw&pxe=1516978804&st=ERlTqgAHVcFh0hbcSiHLpI99v030NvaayeUjaqsX1LVG-Po类似。 zwpXoEoe5UjJ8TitkXQUuTbwIHsDgZrGHZze1Hj0OWLpz7RVfZBt6Mpz
bellow是我的片段,它能够重定向到我想要的页面。但是无法发送标题。
同时视频js喜欢类似的视频播放器无法播放视频(test.php)
//Saved This code as test.php
<?php
$location = file_get_contents("http://0--0.gq/Jio/Bittu_Ghosh_22.php");
header('Location: http://test.m3u8'.$location);
?>
答案 0 :(得分:0)
通过了您的代码,您应该知道您无法通过header()函数发送HTTP标头。但我还可以向你展示一个只能通过GET工作的小技巧。通过curl示例获取令牌。
// test.php
$getToken = "http://0--0.gq/Jio/Bittu_Ghosh_22.php";
$ch = curl_init($getToken);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
$response = curl_getinfo($ch);
// perhaps no http_user_agent (This is what you desire right?)
if(!array_key_exists("http_user_agent", $response))
{
$response['http_user_agent'] = @$_SERVER['HTTP_USER_AGENT'];
}
// Header response are available in $response variable
// Build http query
$query = !empty($data) ? $data.'&user_agent='.$response['http_user_agent'] : '?user_agent='.$response['http_user_agent'];
// now send to http://test.m3u8, if you have right to that page you can grab the user agent from the uri.
header("location: http://test.m3u8{$query}");
// so on test.m3u8 use $_GET['user_agent'];
$userAgent = $_GET['user_agent'];
if($userAgent != "")
{
header('http_user_agent: '.$userAgent);
}
// to check use
print_r(headers_list());