I have currently started helping a friend with his site and he uses the lava function posttohost for his chatbot, now he wants it to use curl instead of fsockopen because of freehost does anyone know how to recode this function?
function PostToHost($host, $path, $data_to_send)
{
$result = "";
$fp = fsockopen($host,80,$errno, $errstr, 30);
if( $fp)
{
fputs($fp, "POST $path HTTP/1.0\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data_to_send) . "\n");
fputs($fp, "Connection: close\n\n");
fputs($fp, $data_to_send);
while(!feof($fp)) {
$result .= fgets($fp, 128);
}
fclose($fp);
return $result;
}
}
foreach ($_SERVER as $server => $value)
{
echo "$server is $value<br />";
}