Technorati and XML-RPC Pinging

I spent some time today to research the ways I could “advertise” my new blog on the web. I knew about del.icio.us and other web goodies like technorati, but I had never actually used them before. After a bit of googling around and a crash course on tags and pinging, I set up a simple XML-RPC ping module that would notify technorati every time i added or edited an entry here.

There seems to be a whole lot of documentation on the subject on technorati’s web site, but it is all geared towards people who use readymade blogging systems like wordpress or textpattern. I don’t like those because I am too curious about technology to use something I did not develop myself. If it can be done, I have to make it myself. Hence this blog.

So if you are interested in installing XML-RPC functionality to your PHP based site, read on, it’s fairly easy. First of all, you need the XML-RPC for PHP package and have a PHP installation with the XML-RPC module. After downloading the package, make sure you have —with-xmlrpc by checking your phpinfo(). The package offers a very easy to use class for creating an XML-RPC client and optionally a server as well. What I needed, and probably what you will need as well, is only the client file, which is conveniently called xmlrpc.inc.

A quick note here, it might not be a problem for an open source class like XML-RPC to use the .inc extension on their files. However, these files can be easily accessed and the code can be seen through a web browser if you are not careful. I simply name all my include files .inc.php for that matter.

After putting the xmlrpc.inc file in your include path, creating a client that sends a simple XML-RPC message is quite easy. Here is an example:

include("./xmlrpc.inc.php");
 
function pingService()
{
// TECHNORATI PING
$client = new xmlrpc_client("/rpc/ping", "rpc.technorati.com", 80);
$message = new xmlrpcmsg("weblogUpdates.ping", array(
new xmlrpcval("The Taylan Pince Blog"),
new xmlrpcval("http://www.taylanpince.com/blog/")
));
 
$client->send($message);
}
 
pingService();

And there it is. If you call the function pingService every time you edit or add a new entry, technorati will check your blog for the updated content, and hopefully you, and I, will both get some nice visitors to our blogs who would read our ramblings and ramble a little bit themselves by leaving comments. The world will be a better place, and we will feel good, and pray the gods of the internet for sending us more and more visitors before we go to bed every night.

Update: I just added a couple of lines of code to ping weblogs.com as well. That place seems to be pinged by a thousand blogs every minute, so I don’t think there is much use for it, but it still is possible:

  // WEBLOGS.COM
$client = new xmlrpc_client("/RPC2", "rpc.weblogs.com", 80);
$message = new xmlrpcmsg("weblogUpdates.ping", array(
new xmlrpcval("The Taylan Pince Blog"),
new xmlrpcval("http://www.taylanpince.com/blog")
));

$client->send($message);

Speak Your Mind

  • Your address won't be shown, it will be used for Gravatar icons if available.

  • Markdown is allowed.

Header 1    Header 2
========    --------

*italic*    **bold**

> A single level blockquote
>> A nested quote

A link: [example](http://url.com "title")
Or a quick URL: <http://url.com>

1. Numbered list item 1
2. Numbered list item 2

* Unordered list item 1
* Unordered list item 2

Any paragraph with 4 spaces to 
the left is a preformatted code block

Language specific code blocks with 
syntax highlighting are supported too:

@@ python
import antigravity
@@ end