I have this script which requires allow_url_fopen = On
which is not a good idea and I want to change curl
. I'll appreciate if any one can help me out with how to do the fputs 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);
}
If I understand your question correctly, you're just looking for how to send the HTTP request (that's what your
fputs($SH, "GET ...")
is doing, that is done usingcurl_exec()
. Seems like this should work.