PHP和Curl没有使用变量

时间:2015-05-30 20:55:36

标签: php html curl

这是我的index.php文件......



<?php

    // Defining the basic cURL function
    function curl($url) {
        $ch = curl_init();  // Initialising cURL
        curl_setopt($ch, CURLOPT_URL, $url);    // Setting cURL's URL option with the $url variable passed into the function
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Setting cURL's option to return the webpage data
        $data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable
        curl_close($ch);    // Closing cURL
        return $data;   // Returning the data from the function
    }
	$url1 = $_GET['link'];
    $response = curl($url1);
    $response = str_replace("./views","http://movietube.pm/views",$response);
	$response = str_replace("./lib","http://movietube.pm/lib",$response);
	$response = str_replace("./assets","http://movietube.pm/assets",$response);
	echo $response;
	?>
&#13;
&#13;
&#13;

// Defining the basic cURL function
function curl($url) {
    $ch = curl_init();  // Initialising cURL
    curl_setopt($ch, CURLOPT_URL, $url);    // Setting cURL's URL option with the $url variable passed into the function
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // Setting cURL's option to return the webpage data
    $data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable
    curl_close($ch);    // Closing cURL
    return $data;   // Returning the data from the function
}
$url1 = $_GET['link'];
$response = curl($url1);
$response = str_replace("./views","http://movietube.pm/views",$response);
$response = str_replace("./lib","http://movietube.pm/lib",$response);
$response = str_replace("./assets","http://movietube.pm/assets",$response);
echo $response;
?>

基本上,我想要它做的是接受输入 www.example.com?link=(link) 执行php后返回页面的HTML ... 在输出上,它正确加载页面,但它没有放入电视节目的东西,如视频播放器,链接或剧集导演...

它的作用......

http://muchmovies.uphero.com/?link=http://www.tvstreaming.cc/watch.php?v=TGmi0OPy0Cc

我想要它做什么...

http://www.tvstreaming.cc/watch.php?v=TGmi0OPy0Cc

感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

也许你有一个php变量$ _GET [&#39; link&#39;]的问题,因为你把这个链接:

http://muchmovies.uphero.com/?link=http://www.tvstreaming.cc/watch.php?v=TGmi0OPy0Cc

请注意,您的查询字符串将是: ?链接= http://www.tvstreaming.cc/watch.php?v=TGmi0OPy0Cc

此查询字符串必须是编码,而您不对其进行编码,因此,变量$ _GET [&#39; link&#39;]将不具有进行卷曲所需的值。

我建议您选择2个选项:

  1. 编码url params
  2. 或者,然后使用base64编码传递url 服务器使用基本解码
  3. 请告诉我这是否是解决方案。