We are about to switch to a new forum software. Until then we have removed the registration on this forum.
If I've posted this in the wrong forum I am so sorry, please tell me where to put it!
I've copied a sketch for searching tweets and so far i've successfully managed to get the tweets to the console, and have a background. What I need to do now is find a way to get that info into the drawing! I'm using the Twitter4j library. (Once I know how to do it I'd like to have the user profile picture, tweet and time to all be seperate, but I think I can sort that by myself after studying the library a bit more).
import twitter4j.util.*;
import twitter4j.*;
import twitter4j.management.*;
import twitter4j.api.*;
import twitter4j.conf.*;
import twitter4j.json.*;
import twitter4j.auth.*;
static String OAuthConsumerKey = "...";
static String OAuthConsumerSecret = "...";
static String AccessToken = "...";
static String AccessTokenSecret = "...";
String keywords[] = {"meaning of life"};
PImage bg;
int y;
TwitterStream twitterStream = new TwitterStreamFactory().getInstance();
void setup(){
size(1920,1080);
noStroke();
connectTwitter();
twitterStream.addListener(listener);
size(1920, 1080);
// The background image must be the same size as the parameters
// into the size() method. In this program, the size of the image
// is 640 x 360 pixels.
bg = loadImage("twitterbackground.jpg");
if (keywords.length==0){
twitterStream.sample();
}
else{
twitterStream.filter(new FilterQuery().track(keywords));
}
}
void draw() {
background(bg);
}
void connectTwitter() {
twitterStream.setOAuthConsumer(OAuthConsumerKey, OAuthConsumerSecret);
AccessToken accessToken = loadAccessToken();
twitterStream.setOAuthAccessToken(accessToken);
}
// Loading up the access token
private static AccessToken loadAccessToken() {
return new AccessToken(AccessToken, AccessTokenSecret);
}
StatusListener listener = new StatusListener(){
public void onStatus(Status status){
String tweet = status.getText();
String user = "@" + status.getUser().getScreenName();
tweet = user + " - " + tweet;
println(tweet);
}
public void onDeletionNotice(StatusDeletionNotice statusDeletionNotice) {
//System.out.println("Got a status deletion notice id:" + statusDeletionNotice.getStatusId());
}
public void onTrackLimitationNotice(int numberOfLimitedStatuses) {
// System.out.println("Got track limitation notice:" + numberOfLimitedStatuses);
}
public void onScrubGeo(long userId, long upToStatusId) {
System.out.println("Got scrub_geo event userId:" + userId + " upToStatusId:" + upToStatusId);
}
public void onException(Exception ex) {
ex.printStackTrace();
}
public void onStallWarning(StallWarning warning){
}
};
Thank you so, so much! <3
Answers
Your subject is useless: most people posting here are new to Processing and ask for help, so it is not informative.
Better edit it and put relevant information, like you seek help about the Twitter library, etc. It is a better way to grab attention from knowledgeable people...
Duplicate post: http://forum.processing.org/two/discussion/10204/twitter4j-library-help
(keys removed)