fsockopen to curl

Started on the old forum in January 2012 · view the original in the archive · old links redirect here

No replies · 440 views · started 14 years ago · 1 min read

djdevil89 Senior · 287 posts #1

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 />";
}

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close