문제
나는 좋은 아이디어가 아니며 allow_url_fopen = On
를 변경하고 싶은 curl
를 필요로하는이 스크립트를 가지고 있습니다.누구든 누구나 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 using curl_exec()
. Seems like this should work.
$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);
제휴하지 않습니다 StackOverflow