package com.blogspot.diegopacheco.httpbuildergroovytwitter.model import groovy.swing.* import java.awt.* import java.awt.event.* import groovyx.net.http.HTTPBuilder import static groovyx.net.http.Method.* import static groovyx.net.http.ContentType.* /** * Script Groovy que atualiza seu stuts no Twitter via HttpBuilder. * * @author Diego Pacheco * @version 1.0 * @since 30/03/2009 * */ def builder = new SwingBuilder() def frame = builder.frame(title:'HttpBuilder Twitter Updater',visible: false,pack: true) { borderLayout() textArea(id: 'updateTextfield',columns: 40,rows: 15,constraints: BorderLayout.NORTH) button(text:'Update',actionPerformed: { def http = new HTTPBuilder('http://twitter.com/statuses/') http.auth.basic 'seuUsuarioDoTwitter','suaSenhaDoTwitter' http.request( POST, XML ) { req -> uri.path = 'update.xml' send URLENC, [status: builder.updateTextfield.text , source:'httpbuilder'] req.params.setBooleanParameter 'http.protocol.expect-continue', false response.success = { resp, xml -> assert resp.statusLine.statusCode == 200 javax.swing.JOptionPane.showMessageDialog(null,"Update realizado com sucesso!") } } },constraints:BorderLayout.SOUTH) } Toolkit tk = Toolkit.getDefaultToolkit() Dimension screenSize = tk.getScreenSize() frame.setLocation((int) (screenSize.width / 2.8), (int) (screenSize.height / 4)) frame.setVisible(true)