I had to look everywhere and pull info from multiple sources to get this stuff to work. Since I don't believe that I'm the first to look into this, I'll provide the code snippet here. This also deals with HTTP authentication and passing parameters:
Code snippet from dyndns.php publishing plugin for wan2web.php (located at http://code.shrum.net)
// Construct the parameter sting
$parameters = "system=" . $_REQUEST['p_system'];
$parameters .="&hostname=" . $_REQUEST['p_hostname'];
$parameters .="&myip=" . $numeric_ip;
$fp = fsockopen($_REQUEST['p_host'], 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)";
} else {
$header .= "GET " . $_REQUEST['p_url'] . " HTTP/1.0\r\n";
$header .= "Host: " . $_REQUEST['p_host'] . "\r\n";
$header .= "Authorization: Basic " . base64_encode($_REQUEST['p_user'] . ":" . $_REQUEST['p_pass']) . "\r\n";
$header .= "User-Agent: WAN2WEB.PHP @ code.shrum.net\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= 'Content-Length: ' . strlen($parameters) . "\r\n\r\n";
if (!$fp) {
echo "$errstr ($errno)";
} else {
fputs ($fp, $header . $parameters);
while (!feof($fp)) { $result = fgets ($fp, 1024); }
}
fclose ($fp);
}
$result will contain the server response to the query. Make sure to change the user-agent to your own setting (dah).
Enjoy!