0) { $path .= '?' . $data; } dfputs($fp, "$method $path HTTP/1.0\r\n"); dfputs($fp, "Host: $host\r\n"); if ($method == 'GET' && strlen($data)>0) { dfputs($fp,"Content-type: application/x-www-form-urlencoded\r\n"); } dfputs($fp, "Content-length: " . strlen($data) . "\r\n"); if (strlen($headers)) { dfputs($fp, "$headers\r\n"); } if ($useragent) { dfputs($fp, "User-Agent: MSIE\r\n"); } dfputs($fp, "Connection: close\r\n\r\n"); if ($method == 'POST') { dfputs($fp, $data); } while (!feof($fp)) { $buf .= fgets($fp,128); } fclose($fp); return $buf; } /* curlToHost -- experiments in curl * ~~~~~~~~~~ * Params: * $url - Full url, with http:// prefix and query string * $method - get or post, case-insensitive * $headers - array of headers * */ function curlToHost($url,$method,$headers=array('')) { ob_start(); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($method)); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); ########### debug curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); // follow redirects recursively curl_exec($ch); curl_close($ch); $ret = ob_get_contents(); ob_end_clean(); return $ret; } ?>