<?php
ping ("http://ping.blogs.yandex.ru/RPC2", "blognam","blogurl");
function ping ($url, $blogname, $blogurl)
{
$tb_send = '<?xml version="1.0"?>
<methodCall>
<methodName>weblogUpdates.ping</methodName>
<params>
<param>
<value>'.$blogname.'</value>
</param>
<param>
<value>'.$blogurl.'</value>
</param>
</params>
</methodCall>';
$target=parse_url($url);
$tb_sock = fsockopen($target["host"], 80);
fputs($tb_sock, "POST " . $target["path"] . $target["query"] . " HTTP/1.1\r\n");
fputs($tb_sock, "User-Agent: The Incutio XML-RPC PHP Library (multicall client)\r\n");
fputs($tb_sock, "Host: " . $target["host"] . "\r\n");
fputs($tb_sock, "Content-Type: text/xml\r\n");
fputs($tb_sock, "Content-length: " . strlen($tb_send) . "\r\n");
fputs($tb_sock, "Connection: close\r\n\r\n");
fputs($tb_sock, $tb_send);
// Gather result
while (!feof($tb_sock)) {
$response .= fgets($tb_sock, 128);
}
// Close socket
fclose($tb_sock);
// Did the trackback ping work
strpos($response, '<error>0</error>') ? $return = true : $return = false;
// send result
return $return;
}
?>
<?php
ping ("http://ping.blogs.yandex.ru/RPC2", "blogname","blogurl");
function ping ($url, $blogname, $blogurl) {
$target=parse_url($url);
# Using the XML-RPC extension to format the XML package
$request = xmlrpc_encode_request("weblogUpdates.ping", array($blogname, $blogurl) );
# Using the cURL extension to send it off,
# first creating a custom header block
$header[] = "Host: " . $target["host"];
$header[] = "Content-type: text/xml";
$header[] = "Content-length: ".strlen($request) . "\r\n";
$header[] = $request;
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $header );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'POST' );
$result = curl_exec( $ch );
curl_close($ch);
return $result;
}
?>