Skip to content

Instantly share code, notes, and snippets.

@sebastienblanc
Created June 2, 2011 19:21

Revisions

  1. sebastienblanc revised this gist Jun 3, 2011. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion twitterSearchDSL.groovy
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,17 @@ http.get( path: 'search.json',
    }
    }]
    }
    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 'groovy'
    search tweets about 'twitter search groovy'
    show current trending topics
  2. sebastienblanc revised this gist Jun 2, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion twitterSearchDSL.groovy
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ 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, count:5] ) { resp, json ->
    query: [q:s2] ) { resp, json ->
    json.results.each {
    println ' ' + it.text
    }
  3. sebastienblanc created this gist Jun 2, 2011.
    18 changes: 18 additions & 0 deletions twitterSearchDSL.groovy
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    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, count:5] ) { resp, json ->
    json.results.each {
    println ' ' + it.text
    }
    }
    }]
    }

    //search twitter DSL
    search tweets about 'groovy'