« VMWare To Buy SpringSource | Main | Some Industry Coverage of the SpringSource Acquisition »

08/12/2009

Bling: Groovy, XMLRPC, and Blog Pings

Bling v0.4 is out. Check out the main bling page for more information.

I have written about Groovy, XML-RPC, and blog pinging several times in the past.  Prior to today, my most recent post about it (published in May 2009) promised to try to clean up what I have and generally improve the flow more.  Over this past weekend, I finally decided to take a stab at doing that.  Bling (real name "bling.groovy") is the result.  (Since I'm still a relative beginner with this, I'm not at all ashamed to admit that it took hours for me to figure out how to iterate through a map in groovy.)  

In it's current iteration, bling will send out xmlrpc-based pings to 18 Blog Directories.  My initial list grew to about 33 hosts but repeated testing indicates that 15 of those hosts were either down temporarily, down for good, or I need to figure out what kind of method calls they are looking for before re-inclusion into the list.  Bling has it's own info page and you can download it from the Downloads page.  Source code is below as well for anyone interested in suggesting improvements.

#!/usr/bin/env groovy
/* bling.groovy - Written by Chris M.
http://blog.techstacks.com/

You will need to modify the valudes for blogTitle and blogURL
so that they match your own blog info.

This script pings 18 different blog directories. Run it when you
update your blog.

Under my own tests, 17 or the 18 endpoints below worked fine. The
only one that posed a problem for me personally was the BlogCatalog
one.

TO DO: Add exception and error handling. Right now, if an error
is received, the script will not resume.

*/

import groovy.net.xmlrpc.*
import groovy.util.slurpersupport.GPathResult

// You'll want to make this next section your own
def blogTitle = "YOUR_BLOG_TITLE_HERE"
def blogURL = "YOUR_BLOG_URL_HERE"

// Set up a map (hash) of popular rpc endpoints
// It is too bad for my syntax highlighter, but some of
// the blogs containing periods in their names necessitated
// placing them in quotes.

def trackbacks = [
Google: 'http://blogsearch.google.com/ping/RPC2',
'Weblogs.com': 'http://rpc.weblogs.com/RPC2',
FeedBurner: 'http://ping.feedburner.com/',
Moreover: 'http://api.moreover.com/RPC2',
Syndic8: 'http://ping.syndic8.com/xmlrpc.php' ,
BlogRolling: 'http://rpc.blogrolling.com/pinger/',
Technorati: 'http://rpc.technorati.com/rpc/ping' ,
'Ping-o-Matic!': 'http://rpc.pingomatic.com/',
NewsGator: 'http://services.newsgator.com/ngws/xmlrpcping.aspx',
Bloglines: 'http://www.bloglines.com/ping',
'Blo.gs': 'http://ping.blo.gs/',
BlogCatalog: 'http://rpc.blogcatalog.com/',
PubSub: 'http://xping.pubsub.com/ping/',
TopicExchange: 'http://topicexchange.com/RPC2',
BlogPeople: 'http://www.blogpeople.net/servlet/weblogUpdates',
'MyBlog.jp': 'http://ping.myblog.jp/',
Goo: 'http://blog.goo.ne.jp/XMLRPC',
]

// IceRocket is separate because their ping method call
// is different from everyone else's--go figure...
def icerocketURL = 'http://rpc.icerocket.com:10080/'
def icerocketServer = new XMLRPCServerProxy(icerocketURL)
def resp = icerocketServer.ping(blogTitle, blogURL)
resp.data instanceof GPathResult

println "IceRocket Ping Result: ${resp.message}"

// Here is the section responsible for iterating through each ping
// url in the trackbacks map.

trackbacks.each {
def url = it.value
def proxy = new XMLRPCServerProxy(url)
def response = proxy.weblogUpdates.ping(blogTitle, blogURL)
response.data instanceof GPathResult
println "${it.key} Ping Result: ${response.message}"
}

The one thing I do need to add in the next release is better error handling. Right now, if you come across an error when iterating through ping services, the script will halt. I need to trap the errors and exceptions and deal with them but I'm still learning how to do that!

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a01156fbc6fe6970c0120a5364da1970c

Listed below are links to weblogs that reference Bling: Groovy, XMLRPC, and Blog Pings:

Comments