The below PHP code is a rather nasty, but effective way to “ping” external syndication networks, such as weblogs.com, blo.gs, and the like.
The main advantage over this simple little subroutine is the lack of required overhead for constructing, and parsing XML within your system. Perhaps you just want to send a notification, and will worry about expanding upon this system later.
One of it’s many pitfalls is, well, it opens a socket from your host, sends a request to the blog system, and waits for any return data before you can proceed. This makes an innefficient flow, but it’s quick, easy, amd mostly painless.
This is heavily based upon YaySoft’s implementation. I’ve only added a few things. For starters, you may now set your hostname and post URI in your request. Secondly, it submits an HTTP Host: Header, which is required by blo.gs, even if that requirement is in the HTTP/1.1 specs.
Calling it is pretty trivial, and fairly easy to understand, if not overly medicated:
$result = pingWeblogs(“My Super HomePage”,”http://www.hereandthere.com/~superduper”,”ping.blo.gs”,”/RPC2”); echo “blo.gs says: $result”;Below, find the simple routine, as slightly modified for use within my Rollator CMS.
function pingWeblogs($name=””, $url=””, $host=””, $hosturi=”/RPC2”) { global $qbtitle, $qbhome; if (!$name) $name = $qbtitle; if (!$url) $url = $qbhome; if (!$host) $host= “rpc.weblogs.com”; $fp = fsockopen(”$host”, 80); if(!$fp) { echo ”$errstr ($errnum)\\n”; $output = “ERROR!”; } else { $len = strlen($name) + strlen($url) + strlen(”