当方mac ver.10.9.2です。
timer機能を使って、ツイートをする機能をプログラムしました。
コンパイルは通ったのですが、ターミナルで実行すると即座に現在のファイルパスが出てきて、実行できていないようです。
lang
1import twitter4j.conf.*; 2import java.util.Timer; 3import java.util.TimerTask; 4import javax.swing.*; 5 6class tweetbot3 { 7 8public static String consumer_key = "4FjtA4e7C8E8JNfCyVRVlrZR"; 9public static String consumer_secret = "jNyrSpNqkh8cmWf2H37R8M5Un3rYWYe27zhMgIYDuUJkExWON"; 10public static String oauth_token = "935689966-eLUfDYXlKRpV3PHPRXOsQ4CEGDO6zZTQpIbtxjb"; 11public static String oauth_token_secret = "x6q2zNpu0cyxoe24OtR6ggMpvZQffiBYufKRRY9HSE8T"; 12 13public static Twitter twitter; 14 15 public static void main(String[] args) { 16 17 new tweetbot3(); 18 } 19 20 public void tweetbot(){ 21 22 ConfigurationBuilder cb = new ConfigurationBuilder(); 23 cb.setOAuthConsumerKey(consumer_key); 24 cb.setOAuthConsumerSecret(consumer_secret); 25 cb.setOAuthAccessToken(oauth_token); 26 cb.setOAuthAccessTokenSecret(oauth_token_secret); 27 TwitterFactory tf = new TwitterFactory(cb.build()); 28 twitter = tf.getInstance(); 29 30 Timer t = new Timer(); 31 t.schedule(new MyTimer(),1000); 32 33 } 34 35 class MyTimer extends TimerTask { 36 37 public void run(){ 38 try{ 39 40twitter.updateStatus("テスト:テストです。"); //tweet 41}catch(Exception e){ 42 e.printStackTrace(); 43 } 44 } 45 } 46 } 47 48コード
回答1件
あなたの回答
tips
プレビュー