Skip to content

Instantly share code, notes, and snippets.

@sebastienblanc
Created June 2, 2011 19:21
Show Gist options
  • Save sebastienblanc/1005096 to your computer and use it in GitHub Desktop.
Save sebastienblanc/1005096 to your computer and use it in GitHub Desktop.
Basic Twitter search DSL
import groovyx.net.http.*
@Grab(group='org.codehaus.groovy.modules.http-builder',
module='http-builder', version='0.5.1' )
def http = new HTTPBuilder( 'http://search.twitter.com/' )
def tweets = 'tweets'
def search = {String s -> [about: {String s2 ->
http.get( path: 'search.json',
query: [q:s2] ) { resp, json ->
json.results.each {
println ' ' + it.text
}
}
}]
}
def show = {String s -> [trending: {String s3 ->
def http = new HTTPBuilder( 'http://api.twitter.com/1/' )
http.get( path: 'trends.json') { resp, json ->
json.trends.each {
println ' ' + it.name
}
}
}]
}
//search twitter DSL
search tweets about 'twitter search groovy'
show current trending topics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment