php - fputs GET to curl -
i have script requires allow_url_fopen = on
not idea , want change curl
. i'll appreciate if 1 can me out how 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 understand question correctly, you're looking how send http request (that's fputs($sh, "get ...")
doing, done using curl_exec()
. seems 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 return output, not display curl_setopt($ch, curlopt_returntransfer, true); //execute request $content = curl_exec($ch);
Comments
Post a Comment