Skip to content

Instantly share code, notes, and snippets.

@fumokmm
Created September 3, 2011 08:11
Show Gist options
  • Save fumokmm/1190848 to your computer and use it in GitHub Desktop.
Save fumokmm/1190848 to your computer and use it in GitHub Desktop.
Groovyでtwitter4jを使ってpostするサンプル
// 参考: http://d.hatena.ne.jp/irof/20110625/p1
// http://twitter4j.org/ja/code-examples.html
@Grab('org.twitter4j:twitter4j-core:latest.integrated')
import twitter4j.*
import twitter4j.conf.*
def conf = new ConfigurationBuilder()
.setOAuthConsumerKey('consumer key')
.setOAuthConsumerSecret('consumer secret')
.setOAuthAccessToken('access token')
.setOAuthAccessTokenSecret('access token secret')
def twitter = new TwitterFactory(conf.build()).instance
def status = twitter.updateStatus('test')
println "Successfully updated the status to [${status.text}]."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment