Sunday, February 18, 2007

Blog ping

One drawback with blogger is that it can only ping weblogs.com. But I want to ping some other index sites too. One way is to go to each site and ping manually, but thats to much work. Another solution is to have a script or something that you run after each time you have written a blog entry.
It hit me that blogger can send a mail each time you enter a new blog entry. So I wrote a python-script yesterday that is trigged by these mails an ping sites using XML-RPC. My script, blogping, reads a config file and ping all services listed in the config file. Then I added an email alias in my email server that run the script when a mail comes in. Last I registered the mail address in blogger.
The alias looks like this in postfix:
blogmail: |"/opt/local/bin/blogping.py -c /opt/local/etc/configfile"

The result of the pings are logged using syslog. You can download the script from here. Run the script with the argument -h to get instructions. You do not have to trig it using mail, it can be executed stand alone.

I have tested the script in both Ubuntu Dapper and Edgy.

3 comments:

Hans Persson said...

It seems to be time for that idea, since I just implemented the same thing, but by using the web interface of the respective service instead. Most of them only require you to fetch a certain specialized URL for your blog, so it's pretty straight-forward.

Perl and WWW::Mechanize are really nice for that sort of thing.

Another reason, of course, for not doing it your way is that I don't have a mail server handy.

Magnus Runesson said...

Hans: The reason I preferd the XML-RPC is that for all services that support this protocol (which is a lot of them) is that I only have to provide a URL that can be found on each service web page. So I do not hav to do any coding at all.

If you using fetchmail and a mailservice (like lysator) that support adding a postfix (not the software) to your username you can send mail from blogger to user+blog@foo.com and let fetchmail run the script.

I think it is only a matter of time until blogger/google supports ping to arbitrary sites.

Hans Persson said...

I definitely hope that Blogger will solve the problem for me sometime soon. Like, I am sure, countless others, I have put a request for that in their ideas queue.