Created
September 27, 2011 14:43
-
-
Save mike-neck/1245219 to your computer and use it in GitHub Desktop.
examine prohibited tweet by Groovy.
This file contains hidden or 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
| @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()} |
This file contains hidden or 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
| 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