Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import twitter4j.conf.*; //http://twitter4j.org/javadoc/index.html
- import twitter4j.*;
- import twitter4j.auth.*;
- import twitter4j.api.*;
- import java.util.*;
- Twitter twitter;
- String searchString = "geug14"; //Change this to what you want to search for.
- List<Status> tweets;
- int currentTweet;
- float previous_w = 300;
- float previous_h=300;
- PFont myFont;
- void setup(){
- smooth();
- size(1800,600);
- float brushSize = 0;
- float targetBrushSize = 0;
- myFont = createFont("GillSans-48.vlw", 24);
- textFont(myFont);
- // Go to developer.twitter.com and get your application keys
- ConfigurationBuilder cb = new ConfigurationBuilder();
- cb.setOAuthConsumerKey("YOURS_GOES_HERE);
- cb.setOAuthConsumerSecret("YOURS_GOES_HERE");
- cb.setOAuthAccessToken("YOURS_GOES_HERE");
- cb.setOAuthAccessTokenSecret("YOURS_GOES_HERE");
- TwitterFactory tf = new TwitterFactory(cb.build());
- twitter = tf.getInstance();
- getNewTweets();
- currentTweet = 0;
- thread("refreshTweets");
- }
- void draw(){
- //Draw the line
- //background(#FA6508);
- smooth();
- fill(33 );
- stroke( #12FA08 );
- strokeWeight(20);
- float w = random(width);
- float h = random(height);
- line(previous_w,previous_h, w, h);
- delay(5000);
- fill(0, 40);
- rect(0, 0, width, height);
- currentTweet = currentTweet + 1;
- if (currentTweet >= tweets.size()){
- currentTweet = 0;
- }
- Status status = tweets.get(currentTweet);
- User user = status.getUser();
- PImage img = loadImage(user.getBiggerProfileImageURL());
- fill(200);
- image(img, w-80,h);
- text(status.getText(),w ,h , 500, 400);
- //translate(w,h);
- previous_w = w;
- previous_h = h;
- }
- void getNewTweets(){
- try {
- Query query = new Query(searchString);
- QueryResult result = twitter.search(query);
- tweets = result.getTweets();
- } catch (TwitterException te) {
- System.out.println("Failed to search tweets: " + te.getMessage());
- System.exit(-1);
- }
- }
- void refreshTweets(){
- while (true){
- getNewTweets();
- println("Updated Tweets");
- delay(30000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement