好的,既然你知道$_POST
它正在工作,那么让我们看看你的 cURL。
这是我通常使用的功能。也许你可以试一试?
代码 :
function getCurl(
$url,
$returntransfer=1, $httpproxytunnel=1, $referer=null,
$useragent=null, $header=null, $httpheader=null,
$proxy=null, $port=null
)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, $returntransfer);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, $httpproxytunnel);
if ($referer!=null)
curl_setopt($ch, CURLOPT_REFERER, $referer);
if ($useragent!=null)
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
if ($header!=null)
curl_setopt($ch, CURLOPT_HEADER, $header);
if ($httpheader!=null)
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
if ($proxy!=null)
curl_setopt($ch, CURLOPT_PROXY, $proxy);
if ($port!=null)
curl_setopt($ch, CURLOPT_PORT, $port);
curl_setopt($ch, CURLOPT_TIMEOUT, 40);
$result['DATA'] = curl_exec($ch);
$result['INFO'] = curl_getinfo($ch);
$result['ERROR'] = curl_error($ch);
return $result;
}
function getFile($url)
{
$data = getCurl($url);
return $data['DATA'];
}
并像这样使用它:
<?php
$fileContents = getFile("http://www.somedomain.com/a-path-to-your-file.html");
echo $fileContents;
?>