2011-02-19 50 views
0

我有这个脚本,需要allow_url_fopen = On这不是一个好主意,我想更改curl。我会很感激,如果任何人可以帮助我如何做fputs GETfputs GET卷曲

$SH = fsockopen($IP, $Port, $errno, $errstr, 30); 
echo $errstr;  
#$ch = curl_init(); 
#curl_setopt($ch, CURLOPT_TIMEOUT, 30); 
#curl_setopt($ch, CURLOPT_URL, $IP.":".$Port); 
#curl_setopt ($ch, CURLOPT_HEADER, 0); 
    if ($SH){ 
     fputs($SH,"GET /7.html HTTP/1.0\r\nUser-Agent: S_Status (Mozilla Compatible)\r\n\r\n"); 
     $content = ""; 
     while(!feof($SH)) { 
      $content .= fgets($SH, 1000); 
      #content .= curl_setopt($ch, CURLOPT_FILE, $SH); 
     } 
     fclose($SH); 
     #curl_close($ch); 
} 
+0

你能否声明一个具体的问题? – DrDol 2011-02-19 00:54:27

回答

0

如果我正确理解你的问题,你只是在寻找如何发送HTTP请求(这是你的fputs($SH, "GET ...")正在做,正在使用curl_exec()完成。看起来这应该工作。

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_TIMEOUT, 30); 
curl_setopt($ch, CURLOPT_PORT, $Port); 
curl_setopt($ch, CURLOPT_URL, $IP . '/7.html'); 
curl_setopt($ch, CURLOPT_USERAGENT, 'S_Status (Mozilla Compatible)'); 
//tell curl to return the output, not display it 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
//execute the request 
$content = curl_exec($ch);