PHP & the XML_RPC ping

Ok, I have this PHP script that I downloaded somewhere, I forget where, and it was written to ping weblogs.com. I was able to modify it to also ping blogrolling, but I couldn’t get it to ping blo.gs. Then I found Ping-O-Matic on scriptygoddess. If I can get the script to just ping them, then I will be pinging many services all at once and not have to configure the script for each one.

The problem is, I am not even sure if it is working.

The only info Ping-O-Matic gives is the url to ping: http://rpc.pingomatic.com/

Here is my code:

[code]$default_name = “#!/usr/bin/mom”;
$default_url = “http://usr-bin-mom.com/”;

function pingWeblogs($name="", $url="") {
global $default_name, $default_url;

if (!$name) $name = $default_name;
if (!$url)  $url  = $default_url;  

$fp = fsockopen("rpc.pingomatic.com", 80, &$errnum, &$errstr);

if(!$fp) {
  echo "$errstr ($errnum)<br>n";
  $output = "ERROR!";
} else  {
  $len = strlen($name) + strlen($url) + strlen("<?xml version="1.0"?><methodCall><methodName>weblogUpdates.ping</methodName><params><param><value></value></param><param><value></value></param></params></methodCall>");
  fputs($fp,"POST /RPC2 HTTP/1.0rn");
  fputs($fp,"User-Agent: Bean's Weblogs.com Updater (PHP Stylin')rn");
  fputs($fp,"Content-Type: text/xmlrn");
  fputs($fp,"Content-length: $lenrnrn");
  fputs($fp,"<?xml version="1.0"?><methodCall><methodName>weblogUpdates.ping</methodName><params><param><value>$name</value></param><param><value>$url</value></param></params></methodCall>");
  $output="";
  while(!feof($fp)) $output.=fgets($fp,4096);
  fclose($fp);
}

$output = preg_replace("/.*</boolean>/si","",$output);
$output = preg_replace("/.*<value>/si","",$output);
$output = preg_replace("/</value>.*/si","",$output);    
return $output;

}[/code]

All I changed was the url to ping. This is what it returns:

23 May 2004, 22:58:31 -- HTTP/1.1 200 OK Date: Mon, 24 May 2004 03:59:16 GMT Server: Apache/1.3.29 (Unix) mod_auth_passthrough/1.8 mod_gzip/1.3.26.1a mod_log_bytes/1.2 mod_bwlimited/1.4 Vary: Accept-Encoding Connection: close Content-Type: text/html

I have no idea what that is. Did it ping? Help?

don’t take this as gospel but I beleive that it is working. I think it is returning a code 200 to you. Hope someone can give you a more definitive answer.

I got it working, thanks.


Michelle Potter, wife to Mark and mom to Aryanna, Aoghdan, Seamus & Hamish
The Mommy Database – http://themommydb.com
#!/usr/bin/mom – http://usr-bin-mom.com

have you any idea how many children it takes to turn off one light in the kitchen? three. it takes one to say, “what light?” and two more to say, “i didn’t turn it on.”
– erma bombeck

Sponsor our Newsletter | Privacy Policy | Terms of Service