fsockopen to curl

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    fsockopen to curl

    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?

    PHP Code:
    function PostToHost($host$path$data_to_send)

    {



                    
    $result "";

            
    $fp fsockopen($host,80,$errno$errstr30);

            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($fp128);

            }

            
    fclose($fp);



            return 
    $result;

            }







    PHP Code:
    foreach ($_SERVER as $server => $value)
    {
    echo 
    "$server is $value<br />";

Working...
X