Created
August 1, 2014 10:00
-
-
Save lhuet/9cc05bab4417c0f1026f to your computer and use it in GitHub Desktop.
Get twitter follosers with twitter4j and 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 = "4.0.2") | |
import twitter4j.* | |
Twitter twitter = new TwitterFactory().instance | |
def user = twitter.verifyCredentials() | |
println "Nb followers de ${user.name} (alias ${user.screenName}) : ${user.followersCount}" | |
long cursor = -1 | |
def followers = twitter.getFollowersList(user.screenName, cursor, 200) | |
followers.each {println "${it.screenName} - ${it.name}"} | |
while (followers.hasNext()) { | |
followers = twitter.getFollowersList(user.screenName, followers.getNextCursor(), 200) | |
followers.each {println "${it.screenName} - ${it.name}"} | |
} |
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
# Credentials from twitter console | |
twitter4j.oauth.consumerKey=<YourConsumerKey> | |
twitter4j.oauth.consumerSecret=<YourConsumerSecret> | |
twitter4j.oauth.accessToken=<YourAccessToken> | |
twitter4j.oauth.accessTokenSecret=<YourAccessTokenSecret> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment