Feeds:
rss
atom
Acceptance Mark
Creative Commons License

Recent techNotes

Please read the Disclaimer
Blog pings · 22 March 05

I’ve already posted this on my personal blog, but I feel it fits more appropriately here:

Many content management software packages are configured to ping one or more syndication services upon submitting a new post. If you’re “rolling your own” blog or content management tool using php, the following code should do the trick:

<?php
require_once "XML/RPC.php";
$postURL = "http://www.myurl.com" ; // change to fit your blog host
$params = array( new XML_RPC_Value( $title, "string" ), new XML_RPC_Value( $postURL, "string" ));
$msg = new XML_RPC_Message("weblogUpdates.ping", $params);
$client = new XML_RPC_CLIENT( "/rpc/ping", "rpc.technorati.com", "80" ) ; // change for other ping hosts
$response = $client->send($msg);
$v = $response->value();
if (!$response->faultCode()) {
$rpcValue = $v->scalarval() ;
$rpcMessage = $rpcValue['message'] ;
$rpcMe = $rpcMessage->me ;
$rpcString = $rpcMe['string'] ;
print "<div>" ;
print $clientHosts[$i] ;
print " Response: <span> " . $rpcString . "</span>";
print "</div>" ;
} else {
print "<div>" ;
print $clientHosts[$i] . " Fault Code: <span> " . $response->faultCode() . "</span>";
print "<div>" ;
print "</div>" ;
print $clientHosts[$i] . " Fault Reason: <span> " . $response->faultString() . "</span>";
print "</div>" ;
}
?>


Comments: