我需要一些PHP的帮助,我想打开url从get-listing.php获得完整的输出。
我试过这个:
<?php
$url = file_get_contents("http://testbox.elementfx.com/get-listing.php");
echo $url;
?>它将向我显示一个空页面,但如果我使用以下命令:
<?php
header('Location: http://testbox.elementfx.com/get-listing.php');
?>它会将我重定向到get-listing.php,我将获得完整的输出。
如果我打开get-listing.php url,我将看到完整的输出,如下所示:
101 ABC FAMILY
http://testbox.elementfx.com/get-listing.php?channels=ABC FAMILY&id=101
Stream 1
102 CBS
http://testbox.elementfx.com/get-listing.php?channels=CBS&id=102
Stream 1
103 CNN USA
http://testbox.elementfx.com/get-listing.php?channels=CNN USA&id=103
Stream 1
105 ESPN USA
http://testbox.elementfx.com/get-listing.php?channels=ESPN USA&id=105
Stream 1
106 FOX News
http://testbox.elementfx.com/get-listing.php?channels=FOX News&id=106
Stream 1
107 Animal Planet
http://testbox.elementfx.com/get-listing.php?channels=Animal Planet&id=107
Stream 1
108 USA Network
http://testbox.elementfx.com/get-listing.php?channels=USA Network&id=108
Stream 1
110 SPIKE
http://testbox.elementfx.com/get-listing.php?channels=SPIKE&id=110
Stream 1
111 BRAVO USA
http://testbox.elementfx.com/get-listing.php?channels=BRAVO USA&id=111
Stream 1
112 BRAVO1
http://testbox.elementfx.com/get-listing.php?channels=BRAVO1&id=112
Stream 1
113 BRAVO2
http://testbox.elementfx.com/get-listing.php?channels=BRAVO2&id=113
Stream 1
114 BRAVO3
http://testbox.elementfx.com/get-listing.php?channels=BRAVO3&id=114
Stream 1
115 BRAVO4
http://testbox.elementfx.com/get-listing.php?channels=BRAVO4&id=115
Stream 1
116 BRAVO5
http://testbox.elementfx.com/get-listing.php?channels=BRAVO5&id=116
Stream 1
117 BRAVO6
http://testbox.elementfx.com/get-listing.php?channels=BRAVO6&id=117
Stream 1
118 BRAVO7
http://testbox.elementfx.com/get-listing.php?channels=BRAVO7&id=118
Stream 1如何在不重定向的情况下打开PHP页面中的url以获得完整的输出?
发布于 2014-03-24 00:46:49
要使用file_get_contents从url检索内容,应在php.ini中将allow_url_fopen设置配置为On
发布于 2014-03-24 00:41:19
从此处使用此类httpclient
它很容易使用
include("HttpClient.class.php");
$client = new HttpClient('testbox.elementfx.com');
$data=$client->get('http://testbox.elementfx.com/get-listing.php')
$fulldata=$client->getContent();或包含使用include()
像这样
include ("http://testbox.elementfx.com/get-listing.php"); (not recommended security issues)查看您的php.ini并确保allow_url_include设置为1。重新启动HTTPD,完成。
发布于 2014-04-08 00:51:52
您最好使用cURL
$url="http://adfoc.us/1575051";
$ch = curl_init();
$header=array('GET /1575051 HTTP/1.1',
'Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language:en-US,en;q=0.8',
'Cache-Control:max-age=0',
'Connection:keep-alive',
'Host:adfoc.us',
'User-Agent:Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36',
);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,0);
curl_setopt( $ch, CURLOPT_COOKIESESSION, true );
curl_setopt($ch,CURLOPT_COOKIEFILE,'cookies.txt');
curl_setopt($ch,CURLOPT_COOKIEJAR,'cookies.txt');
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
$result=curl_exec($ch);
curl_close($ch);https://stackoverflow.com/questions/22593627
复制相似问题