Skip to content

Instantly share code, notes, and snippets.

@mike-neck
Created September 27, 2011 14:43
Show Gist options
  • Select an option

  • Save mike-neck/1245219 to your computer and use it in GitHub Desktop.

Select an option

Save mike-neck/1245219 to your computer and use it in GitHub Desktop.
examine prohibited tweet by Groovy.
@Grab(group='org.twitter4j', module='twitter4j-core', version='2.2.4')
import twitter4j.*
import twitter4j.auth.*
import twitter4j.conf.*
def consumerKey = 'consumerKey'
def consumerSecret = 'consumerSecret'
def accessToken = 'accessToken'
def accessTokenSecret = 'accessTokenSecret'
def conf =
new ConfigurationBuilder()
.setOAuthConsumerKey(consumerKey)
.setOAuthConsumerSecret(consumerSecret)
.setOAuthAccessToken(accessToken)
.setOAuthAccessTokenSecret(accessTokenSecret).build()
def twitter = new TwitterFactory(conf).getInstance()
def results = []
(65..90).each {
def tweets = "(${it as char})"
try{
def result = twitter.updateStatus(tweets)
results << new Result(id : it, expected : tweets, result : result.text, status : result.id)
}catch(TwitterException e) {
results << new Result(id : it, expected : tweets, result : '', status : -1)
}
}
results.each { println it.showResult()}
class Result {
int id
long status
String expected
String result
String showResult(){
return "success : ${expected == result}, id : ${id}, expected : ${expected}, result : ${result}"
}
@Override
String toString() {
return "<id : ${id}, expected : ${expected}, result : ${result}, status : ${status}>"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment