Sam korzystam z tego. Do funkcji przekazujesz tytuł bloga i adres url. W pliku pinglist.txt musisz mieć adresy, które chcesz pingować, każdy w osobnej linii.
function ping($blogTitle, $blogUrl) {
// Please, edit these variables to your needs
//$blogTitle="tytuł!";
//$blogUrl="http://www.adres.pl/all.html";
$pingListFile="pinglist.txt";
$showDebugInfo=FALSE; // Do you want verbose output?
// Stop editing here
// PingRPC.php
//
// 2007 by Sascha Tayefeh
// <a href="http://www.tayefeh.de" target="_blank">http://www.tayefeh.de</a>
//
// This is a PHP5-based XML-RPC ping script. It reads a one-column
// fully qualified URL-list from a file ($pingListFile). Here is
// an example how this file must look like:
// ----------------------
// <a href="http://rpc.icerocket.com:10080/" target="_blank">http://rpc.icerocket.com:10080/</a>
// <a href="http://rpc.pingomatic.com/" target="_blank">http://rpc.pingomatic.com/</a>
// <a href="http://rpc.technorati.com/rpc/ping" target="_blank">http://rpc.technorati.com/rpc/ping</a>
// <a href="http://rpc.weblogs.com/RPC2" target="_blank">http://rpc.weblogs.com/RPC2</a>
// ----------------------
$replacementCount=0;
$userAgent="pingrpc.php by tayefeh";
// Read pinglist file. Must contain one fully qualified URL
// (e.g: <a href="http://rpc.technorati.com/rpc/ping)" target="_blank">http://rpc.technorati.com/rpc/ping)</a> PER LINE (->
// delimiter is an ASCII-linebreak)
$fp=fopen($pingListFile,"r"); {
// get the hostname
$host=$line; // Make a copy of $line
$host=preg_replace('/^.*http:\/\//','',$host); // Delete anything before http:// $host=preg_replace('/\/.*$/','',$host); // Delete anything after behind the hostname
// get the path
$path=$line; // Make another copy of $line
$path=preg_replace('/^.*http:\/\/[a-zA-Z0-9\-_\.]*\.[a-zA-Z]{1,3}\//','',$path,-1
,$replacementCount); // Delete anything before the path if(!$replacementCount) $path=''; // if there was no replacement (i.e. no explicit path), act appropiately
if($host) $myList[$host]=$path;
}
echo "<h1>Ping process started</h1>";
echo "<p>Reading URLs from file $pingListFile: ";
// Use DOM to create the XML-File
$xml= new DOMDocument('1.0');
$xml->formatOutput=true;
$xml->preserveWhiteSpace=false;
$xml->substituteEntities=false;
// Create the xml structure
$methodCall=$xml->appendChild($xml->createElement('methodCall'));
$methodName=$methodCall->appendChild($xml->createElement('methodName'));
$params=$methodCall->appendChild($xml->createElement('params'));
$param[1]=$params->appendChild($xml->createElement('param'));
$value[1]=$param[1]->appendChild($xml->createElement('value'));
$param[2]=$params->appendChild($xml->createElement('param'));
$value[2]=$param[2]->appendChild($xml->createElement('value'));
// Set the node values
$methodName->nodeValue="weblogUpdates.ping";
$value[1]->nodeValue=$blogTitle;
$value[2]->nodeValue=$blogUrl;
$xmlrpcReq = $xml->saveXML(); // Write the document into a string
$xmlrpcLength = strlen( $xmlrpcReq ); // Get the string length.
echo "Here's the xml-message I generated (size: $xmlrpcLength bytes):";
// Proceed every link read from file
foreach ( $myList as $host => $path)
{
if($showDebugInfo) echo "<hr/>";
echo "<dt><strong>Pinging host: $host </strong>"; $httpReq = "POST /" . $path . " HTTP/1.0\r\n";
$httpReq .= "User-Agent: " . $userAgent. "\r\n";
$httpReq .= "Host: " . $host . "\r\n";
$httpReq .= "Content-Type: text/xml\r\n";
$httpReq .= "Content-length: $xmlrpcLength\r\n\r\n";
$httpReq .= "$xmlrpcReq\r\n";
if($showDebugInfo)
{
echo "<dd><strong>Request:</strong><pre><span style=\"color: #cc9900\">".htmlentities($httpReq)."</span></pre>"; echo "<strong>Answer</strong>:<span style=\"color: #99cc00\"><pre>"; }
// Actually, send ping
{
@fputs( $pinghandle, $httpReq ); while ( ! feof( $pinghandle ) ) {
$pingresponse = @fgets( $pinghandle, 128
); }
}
if($showDebugInfo) echo "</span></pre></dd>"; }
}