Created
June 2, 2011 19:21
-
-
Save sebastienblanc/1005096 to your computer and use it in GitHub Desktop.
Basic Twitter search DSL
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.* | |
@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