Skip to content

Instantly share code, notes, and snippets.

@nazt
Created April 8, 2010 13:43
Show Gist options
  • Save nazt/360079 to your computer and use it in GitHub Desktop.
Save nazt/360079 to your computer and use it in GitHub Desktop.
import groovyx.net.http.RESTClient
import groovy.util.slurpersupport.GPathResult
import static groovyx.net.http.ContentType.*
def userName= 'user'
def passwd ='pass'
twitter = new RESTClient( 'https://twitter.com/statuses/' )
twitter.auth.basic userName, passwd
def msg = "I'm using HTTPBuilder's RESTClient on ${new Date()}"
resp = twitter.post( path : 'update.xml',
body : [ status:msg, source:'httpbuilder' ],
requestContentType : URLENC )
assert resp.status == 200
assert ( resp.data instanceof GPathResult ) // parsed using XmlSlurper
assert resp.data.text == msg
assert resp.data.user.screen_name == userName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment