We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hi all,
I really need help. I haven't used processing for three years and my mind is totally blank on how to update this old code i wrote and make it run on my new computer and with whatever changes processing and Twitter may have made.
I wrote this code so that it would search and stream tweets that contained a specific phrase and play those stream tweets on a screen.
I have the old code but it won't run anymore
it could be something very basic like i am missing a library but it feels like more.
I could really really use some help. and would super interested in even emailing someone about it if anyone would be down (i need to get this up and running for porject and i am in tight space)
here is my old code
import twitter4j.conf.*;
import twitter4j.*;
import twitter4j.auth.*;
import twitter4j.api.*;
import java.util.*;
Twitter twitter;
String searchString = "Rest In Peace";
List<Status> tweets;
int currentTweet;
int offsetx, offsety;
PFont f;
float x;
void setup()
{
f = loadFont("HelveticaNeue-Bold-90.vlw");
size(displayWidth, displayHeight);
offsetx=(displayWidth-10);
offsety=(displayHeight-10);
;
ConfigurationBuilder cb = new ConfigurationBuilder();
TwitterFactory tf = new TwitterFactory(cb.build());
twitter = tf.getInstance();
getNewTweets();
currentTweet = 0;
}
void draw()
{
background(255);
textAlign (CENTER, TOP);
textFont(f, 90);
currentTweet = currentTweet + 1;
if (currentTweet >= tweets.size())
{
print("getting new tweets");
currentTweet = 0;
getNewTweets();
}
Status status = tweets.get(currentTweet);
fill(0);
text(status.getText(), 0, 400, displayWidth, displayHeight);
delay(8000);
}
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);
}
//going to print out new tweets
int curt = 0;
for(int i=0; i< tweets.size(); i++){
Status status = tweets.get(curt);
print(status.getText() + "\n");
curt = curt + 1;
}
}
void refreshTweets()
{
while (true)
{
getNewTweets();
println("Updated Tweets");
delay(30000);
}
}
and this is the error that i am getting
Failed to search tweets: Connection refused (Connection refused)
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help → Troubleshooting.
Answers
Please format your code. Edit your post (gear on top right side of any of your posts), select your code and hit ctrl+o. Leave an empty line above and below your block of code. Details here: https://forum.processing.org/two/discussion/15473/readme-how-to-format-code-and-text
Also, don't past your access tokens. Although if you haven't used them in three years, they might have expired.
Kf
(i've done it)
In addition to confirming that your API key still works, you may also want to check recent forum posts re:Twitter:
This could assist as well: http://shiffman.net/a2z/twitter-bots/
It is safe to assume you have your local server setup and running in your machine?
Kf
Hey so i fixed this problem thanks. would anyone know how to skip retweets and remove the url codes/twitter hanldes
Can you share your solution please? Also:
If you want more feedback, you will need to provide more details or even some code.
Kf