卷曲(无法隐藏输出)

时间:2015-07-12 20:02:34

标签: php curl

我实现了这个功能:

function makeRequest($url,$browser,$ip,$cookie = false,$referrer = null)
{
if($referrer==null)
{
    $refferer = 'http://google.com';
}
$headers = array();    
$headers[] = "HTTP_X_FORWARDED_FOR: ".$ip;    
$headers[] = "X_FORWARDED_FOR: ".$ip;    
$headers[] = "REMOTE_ADDR:". $ip;    
$headers[] = "REFERRER: ".$referrer;    
$headers[] = $browser;
$ch = curl_init();   
curl_setopt($ch, CURLOPT_URL, $url);   
curl_setopt($ch, CURLOPT_COOKIESESSION, true );    
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); 
if($cookie!==false)
{
    curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_HEADER, false);  
}    
else
{
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_HEADER, 1);  
}
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);  
curl_setopt($ch, CURLOPT_REFERER, $referrer);

if($cookie==false)
{
    $return = curl_exec($ch);
}
else
{
    $return = 'hidden content';
    curl_exec($ch);
}
curl_close($ch);
 return $x;
}

但每次返回内容时,如果我已将cookie设置为false。 我不知道我该怎么做。

我尝试过:

CURLOPT_RETURNTRANSFER, CURLOPT_VERBOSE, CURLOPT_HEADER

但没有......

谢谢(对不起我的英文)

0 个答案:

没有答案