Created
April 8, 2010 13:55
-
-
Save nazt/360090 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.client.params.setBooleanParameter 'http.protocol.expect-continue', false | |
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