« Lenya: Building With Tomcat 6 | Main | Tomcat Management: Setting up the Tomcat Manager Application »

05/04/2009

Groovy HTTPBuilder and XMLRPC: Another Blog Ping Script

Here's another blog ping script—this one is for Moreover. There are two versions of this script; one uses the HTTPBuilder module and the other uses the XMLRPC module.

ping Moreover using HTTP

#!/usr/bin/env groovy 

import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.Method.GET
import static groovyx.net.http.ContentType.TEXT

def http = new HTTPBuilder('http://rpc.weblogs.com/pingSiteForm?name=Blogging%20Techstacks&url=http%3A%2F%2Fblog.techstacks.com&changesURL=http%3A%2F%2Ffeeds2.feedburner.com/BloggingTechstacks')
http.request(GET,TEXT) { req ->
headers.'User-Agent' = 'GroovyHTTPBuilderScript/0.4'
headers.'Cache-Control' = 'no-cache'
headers.'Connection' = 'close'
req.getParams().setParameter("http.connection.timeout", new Integer(5000));
req.getParams().setParameter("http.socket.timeout", new Integer(5000));

response.success = { resp, reader ->
println "-----Response-----"
println "${resp.statusLine}"
println System.out << reader
println "\n------------------"
}
response.failure = { resp ->
println "Something happened: ${resp.statusLine}"
}
}

ping Moreover using XML-RPC

#!/usr/bin/env groovy

import groovy.net.xmlrpc.*

def server = new XMLRPCServerProxy("http://rpc.weblogs.com/RPC2")

def result = server.weblogUpdates.extendedPing("blogging techstacks" , "http://blog.techstacks.com/" , "http://feeds2.feedburner.com/BloggingTechstacks")

if (result != null)
println "Thanks for the ping!"

TrackBack

TrackBack URL for this entry:
https://www.typepad.com/services/trackback/6a01156fbc6fe6970c0115722883d9970b

Listed below are links to weblogs that reference Groovy HTTPBuilder and XMLRPC: Another Blog Ping Script:

Comments