« XFireFault: Can Not Invoke Service over SSL | Main | Groovy Script: Get All SSL Ciphers Supported by a Site »

08/21/2009

Bling v0.2 Released - Groovy-Based Blog Ping Tool

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

Version 2.0 has been released.  It adds some exception handling, nicer formatting of responses, and removes one service to lower the number of XMLRPC-based blog ping services to 17. (TopicExchange didn't ever provide a response so it's been dropped for now). I am semi-continually experimenting with a larger list of services and more will be added over time if warranted.

Head on over to the downloads page if you are interested in downloading a binary version. In addition, the main Bling page has been updated.

Source for this release is below. This is my first post using Alex Gorbatchev's SyntaxHighlighter, so hopefully posts like these will look even prettier!

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

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

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

v0.1 Initial release targeting 18 services.
v0.2 Reworked the output so that everything is nice and lined up.  Added basic exception handling when service responds with a connection refused. Also added logic branch so that if the service responds with an error, I now just display a generic 'ping failed' error. Removed TopicExchange as a service so now there are only 17 services getting pinged (but one of them is ping-o-matic).

To-Do: Add some kind of debug option. Add additional exception catches.
*/

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':   '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' ,
 PingoMatic:  '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/',
 'MyBlog.jp':  'http://ping.myblog.jp/',
 'Goo\t':   'http://blog.goo.ne.jp/XMLRPC',
 BlogPeople:  'http://www.blogpeople.net/servlet/weblogUpdates',
 ]

// Set up canned responses to make the outputted responses nicer.
// Previously, the output used the literal response from the endpoint
// which did not look all that nice in a terminal window.
def weal = "Thanks for the ping!"
def woe = "PING ATTEMPT FAILED."

// IceRocket is separate because their ping method call
// is different from everyone else's--go figure...


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

println "====PING RESULTS===="

try{
 def icerocketURL = 'http://rpc.icerocket.com:10080/'
 def icerocketServer = new XMLRPCServerProxy(icerocketURL)
 resp = icerocketServer.ping(blogTitle, blogURL)
 resp.data instanceof GPathResult

 if (!resp.flerror) 
 println " Icerocket\t${weal}"
 else
 println " IceRocket\t${woe}"

}catch(ConnectException ex){
 println " IceRocket\t${woe}" 
 
}

trackbacks.each {
 try{
 def url = it.value
 def proxy = new XMLRPCServerProxy(url)
 response = proxy.weblogUpdates.ping(blogTitle, blogURL)
  response.data instanceof GPathResult

 if (!resp.flerror)
  println " ${it.key}\t${weal}"
  else
  println " ${it.key}\t${woe}"

 }catch(ConnectException ex) {
  println " ${it.key}\t${woe}"
  
 } 
}

TrackBack

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

Listed below are links to weblogs that reference Bling v0.2 Released - Groovy-Based Blog Ping Tool:

Comments