Permalink
Browse files

now geolocation and retweet count in the logfile

  • Loading branch information...
1 parent 0ec11ec commit a4415d47dc12a9753b4cef23e3f1a173ecfcb33d @kiilo committed Nov 22, 2011
@@ -1,6 +1,7 @@
import twitter4j.*;
import java.lang.Exception;
+
//TwitterConnectStream twitterIn;
Twitter twitterOut;
//AccessToken accessToken;
@@ -51,8 +52,20 @@ void SetupTwitter() {
StatusListener twitterIn = new StatusListener() {
public void onStatus(Status status) {
- // println("@" + status.getUser().getScreenName() + " - " + status.getText());
- output.println(TimeStamp()+", @" + status.getUser().getScreenName() + ", " + status.getText());
+ double Longitude;
+ double Latitude;
+ GeoLocation GeoLoc = status.getGeoLocation();
+ if (GeoLoc != null) {
+ //println("YES got a location");
+ Longitude = GeoLoc.getLongitude();
+ Latitude = GeoLoc.getLatitude();
+ }
+ else {
+ Longitude = 0;
+ Latitude = 0;
+ }
+ println( status.getCreatedAt() + "\t" + Latitude + "\t" + Longitude + "\t" + status.getRetweetCount() + "\t" + status.getUser().getScreenName() + "\t" + status.getText());
+ output.println(status.getCreatedAt() +"\t" + Latitude + "\t" + Longitude + "\t" + status.getRetweetCount() + "\t"+ status.getUser().getScreenName() + "\t" + status.getText());
output.flush();
TwitterToOsc(status.getUser().getScreenName(), status.getText());
}
@@ -22,6 +22,8 @@ String pin = "";
RequestToken requestToken = null;
AccessToken accessToken = null;
+PrintWriter output;
+
void SetupTwitter() {
//twitterIn = new TwitterConnectStream();
@@ -44,11 +46,26 @@ void SetupTwitter() {
// println(ex);
// }
ActivityLogAddLine("twitter connector ready");
+ output = createWriter("log.txt");
StatusListener twitterIn = new StatusListener() {
public void onStatus(Status status) {
- System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
+ double Longitude;
+ double Latitude;
+ GeoLocation GeoLoc = status.getGeoLocation();
+ if (GeoLoc != null) {
+ //println("YES got a location");
+ Longitude = GeoLoc.getLongitude();
+ Latitude = GeoLoc.getLatitude();
+ }
+ else {
+ Longitude = 0;
+ Latitude = 0;
+ }
+ println( TimeStamp()+"\t" + Latitude + "\t" + Longitude + "\t"+ status.getUser().getScreenName() + "\t" + status.getText());
+ output.println(TimeStamp()+"\t" + Latitude + "\t" + Longitude + "\t"+ status.getUser().getScreenName() + "\t" + status.getText());
+ output.flush();
TwitterToOsc(status.getUser().getScreenName(), status.getText());
}
@@ -178,14 +178,18 @@ void ActivityLogAddLine(String aTextLine) {
}
int length = aTextLine.replaceAll("[^\\p{ASCII}]","*").length();
if (length > 12) {length = 12;}
- String TimeStamp = String.valueOf(day())+"."+String.valueOf(month())+"."+String.valueOf(year())+" "+String.valueOf(hour())+":"+String.valueOf(minute())+":"+String.valueOf(second());
+ String MyTimeStamp = String.valueOf(day())+"."+String.valueOf(month())+"."+String.valueOf(year())+" "+String.valueOf(hour())+":"+String.valueOf(minute())+":"+String.valueOf(second());
//String aMessage = aTextLine.replaceAll(".[^\\p{ASCII}]","*");
// !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`
String aMessage = aTextLine.replaceAll("[^A-Za-z !\"#$%&'()*+-,./0123456789:;<=>?@^_`]","*");
- ActivityLogTextarea.setText(ActivityLogTextarea.text()+TimeStamp+" "+aMessage+"\n");
+ ActivityLogTextarea.setText(ActivityLogTextarea.text()+MyTimeStamp+" "+aMessage+"\n");
//ActivityLogTextarea.setText(ActivityLogTextarea.text()+String.valueOf(day())+"."+String.valueOf(month())+"."+String.valueOf(year())+" "+String.valueOf(hour())+":"+String.valueOf(minute())+":"+String.valueOf(second())+" "+"\n");
}
+String TimeStamp() {
+ return String.valueOf(day())+"."+String.valueOf(month())+"."+String.valueOf(year())+" "+String.valueOf(hour())+":"+String.valueOf(minute())+":"+String.valueOf(second());
+}
+
public void PIN(String theText) {
// receiving text from controller PIN
pin = theText;
Binary file not shown.
@@ -67,7 +67,7 @@ public void draw() {
//PImage b = loadImage("backgr.png");
background(backgr);
controlP5.draw();
- //delay(20);
+ delay(5);
}
@@ -254,6 +254,8 @@ public void SaveProperties() {
RequestToken requestToken = null;
AccessToken accessToken = null;
+PrintWriter output;
+
public void SetupTwitter() {
//twitterIn = new TwitterConnectStream();
@@ -276,11 +278,26 @@ public void SetupTwitter() {
// println(ex);
// }
ActivityLogAddLine("twitter connector ready");
+ output = createWriter("log.txt");
StatusListener twitterIn = new StatusListener() {
public void onStatus(Status status) {
- System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
+ double Longitude;
+ double Latitude;
+ GeoLocation GeoLoc = status.getGeoLocation();
+ if (GeoLoc != null) {
+ //println("YES got a location");
+ Longitude = GeoLoc.getLongitude();
+ Latitude = GeoLoc.getLatitude();
+ }
+ else {
+ Longitude = 0;
+ Latitude = 0;
+ }
+ println( TimeStamp()+"\t" + Latitude + "\t" + Longitude + "\t"+ status.getUser().getScreenName() + "\t" + status.getText());
+ output.println(TimeStamp()+"\t" + Latitude + "\t" + Longitude + "\t"+ status.getUser().getScreenName() + "\t" + status.getText());
+ output.flush();
TwitterToOsc(status.getUser().getScreenName(), status.getText());
}
@@ -637,14 +654,18 @@ public void ActivityLogAddLine(String aTextLine) {
}
int length = aTextLine.replaceAll("[^\\p{ASCII}]","*").length();
if (length > 12) {length = 12;}
- String TimeStamp = String.valueOf(day())+"."+String.valueOf(month())+"."+String.valueOf(year())+" "+String.valueOf(hour())+":"+String.valueOf(minute())+":"+String.valueOf(second());
+ String MyTimeStamp = String.valueOf(day())+"."+String.valueOf(month())+"."+String.valueOf(year())+" "+String.valueOf(hour())+":"+String.valueOf(minute())+":"+String.valueOf(second());
//String aMessage = aTextLine.replaceAll(".[^\\p{ASCII}]","*");
// !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`
String aMessage = aTextLine.replaceAll("[^A-Za-z !\"#$%&'()*+-,./0123456789:;<=>?@^_`]","*");
- ActivityLogTextarea.setText(ActivityLogTextarea.text()+TimeStamp+" "+aMessage+"\n");
+ ActivityLogTextarea.setText(ActivityLogTextarea.text()+MyTimeStamp+" "+aMessage+"\n");
//ActivityLogTextarea.setText(ActivityLogTextarea.text()+String.valueOf(day())+"."+String.valueOf(month())+"."+String.valueOf(year())+" "+String.valueOf(hour())+":"+String.valueOf(minute())+":"+String.valueOf(second())+" "+"\n");
}
+public String TimeStamp() {
+ return String.valueOf(day())+"."+String.valueOf(month())+"."+String.valueOf(year())+" "+String.valueOf(hour())+":"+String.valueOf(minute())+":"+String.valueOf(second());
+}
+
public void PIN(String theText) {
// receiving text from controller PIN
pin = theText;
@@ -25,7 +25,7 @@ void draw() {
//PImage b = loadImage("backgr.png");
background(backgr);
controlP5.draw();
- //delay(20);
+ delay(5);
}
@@ -1,13 +1,13 @@
# TWITTER gateway configuration
-#Mon Oct 24 16:50:21 EDT 2011
+#Tue Nov 22 15:22:09 CET 2011
osc.receiving.port=8020
osc.address.send=/fromTwitter
twitter.ConsumerSecret=q5ECt4fqWBmscfoMGNzpQXnp9TGt9W653m4zoA4sqY
twitter.AccessToken=
osc.address.recv=/toTwitter
twitter.followIDs=62130733
-osc.destination.host=localhost
+osc.destination.host=192.168.1.255
twitter.AccessTokenSecret=
twitter.ConsumerKey=0A8dJL19TWgqrKl6VgsiAg
-twitter.trackwords=\#OWS occupy
+twitter.trackwords=occupy \#OWS revolution
osc.destination.port=9000
@@ -51,8 +51,20 @@ void SetupTwitter() {
StatusListener twitterIn = new StatusListener() {
public void onStatus(Status status) {
- System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
- output.println(TimeStamp()+", @" + status.getUser().getScreenName() + ", " + status.getText());
+ double Longitude;
+ double Latitude;
+ GeoLocation GeoLoc = status.getGeoLocation();
+ if (GeoLoc != null) {
+ //println("YES got a location");
+ Longitude = GeoLoc.getLongitude();
+ Latitude = GeoLoc.getLatitude();
+ }
+ else {
+ Longitude = 0;
+ Latitude = 0;
+ }
+ println( TimeStamp()+"\t" + Latitude + "\t" + Longitude + "\t"+ status.getUser().getScreenName() + "\t" + status.getText());
+ output.println(TimeStamp()+"\t" + Latitude + "\t" + Longitude + "\t"+ status.getUser().getScreenName() + "\t" + status.getText());
output.flush();
TwitterToOsc(status.getUser().getScreenName(), status.getText());
}
@@ -25,7 +25,7 @@ void draw() {
//PImage b = loadImage("backgr.png");
background(backgr);
controlP5.draw();
- //delay(20);
+ delay(5);
}
@@ -51,8 +51,20 @@ void SetupTwitter() {
StatusListener twitterIn = new StatusListener() {
public void onStatus(Status status) {
- System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
- output.println(TimeStamp()+", @" + status.getUser().getScreenName() + ", " + status.getText());
+ double Longitude;
+ double Latitude;
+ GeoLocation GeoLoc = status.getGeoLocation();
+ if (GeoLoc != null) {
+ //println("YES got a location");
+ Longitude = GeoLoc.getLongitude();
+ Latitude = GeoLoc.getLatitude();
+ }
+ else {
+ Longitude = 0;
+ Latitude = 0;
+ }
+ println( TimeStamp()+"\t" + Latitude + "\t" + Longitude + "\t"+ status.getUser().getScreenName() + "\t" + status.getText());
+ output.println(TimeStamp()+"\t" + Latitude + "\t" + Longitude + "\t"+ status.getUser().getScreenName() + "\t" + status.getText());
output.flush();
TwitterToOsc(status.getUser().getScreenName(), status.getText());
}
@@ -25,7 +25,7 @@ void draw() {
//PImage b = loadImage("backgr.png");
background(backgr);
controlP5.draw();
- //delay(20);
+ delay(5);
}
@@ -1,13 +1,13 @@
# TWITTER gateway configuration
-#Mon Oct 24 16:50:21 EDT 2011
+#Tue Nov 22 15:22:09 CET 2011
osc.receiving.port=8020
osc.address.send=/fromTwitter
twitter.ConsumerSecret=q5ECt4fqWBmscfoMGNzpQXnp9TGt9W653m4zoA4sqY
twitter.AccessToken=
osc.address.recv=/toTwitter
twitter.followIDs=62130733
-osc.destination.host=localhost
+osc.destination.host=192.168.1.255
twitter.AccessTokenSecret=
twitter.ConsumerKey=0A8dJL19TWgqrKl6VgsiAg
-twitter.trackwords=\#OWS occupy
+twitter.trackwords=occupy \#OWS revolution
osc.destination.port=9000
@@ -51,8 +51,20 @@ void SetupTwitter() {
StatusListener twitterIn = new StatusListener() {
public void onStatus(Status status) {
- System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
- output.println(TimeStamp()+", @" + status.getUser().getScreenName() + ", " + status.getText());
+ double Longitude;
+ double Latitude;
+ GeoLocation GeoLoc = status.getGeoLocation();
+ if (GeoLoc != null) {
+ //println("YES got a location");
+ Longitude = GeoLoc.getLongitude();
+ Latitude = GeoLoc.getLatitude();
+ }
+ else {
+ Longitude = 0;
+ Latitude = 0;
+ }
+ println( TimeStamp()+"\t" + Latitude + "\t" + Longitude + "\t"+ status.getUser().getScreenName() + "\t" + status.getText());
+ output.println(TimeStamp()+"\t" + Latitude + "\t" + Longitude + "\t"+ status.getUser().getScreenName() + "\t" + status.getText());
output.flush();
TwitterToOsc(status.getUser().getScreenName(), status.getText());
}
@@ -67,7 +67,7 @@ public void draw() {
//PImage b = loadImage("backgr.png");
background(backgr);
controlP5.draw();
- //delay(20);
+ delay(5);
}
@@ -283,8 +283,20 @@ public void SetupTwitter() {
StatusListener twitterIn = new StatusListener() {
public void onStatus(Status status) {
- System.out.println("@" + status.getUser().getScreenName() + " - " + status.getText());
- output.println(TimeStamp()+", @" + status.getUser().getScreenName() + ", " + status.getText());
+ double Longitude;
+ double Latitude;
+ GeoLocation GeoLoc = status.getGeoLocation();
+ if (GeoLoc != null) {
+ //println("YES got a location");
+ Longitude = GeoLoc.getLongitude();
+ Latitude = GeoLoc.getLatitude();
+ }
+ else {
+ Longitude = 0;
+ Latitude = 0;
+ }
+ println( TimeStamp()+"\t" + Latitude + "\t" + Longitude + "\t"+ status.getUser().getScreenName() + "\t" + status.getText());
+ output.println(TimeStamp()+"\t" + Latitude + "\t" + Longitude + "\t"+ status.getUser().getScreenName() + "\t" + status.getText());
output.flush();
TwitterToOsc(status.getUser().getScreenName(), status.getText());
}
@@ -25,7 +25,7 @@ void draw() {
//PImage b = loadImage("backgr.png");
background(backgr);
controlP5.draw();
- //delay(20);
+ delay(5);
}
@@ -1,13 +1,13 @@
# TWITTER gateway configuration
-#Mon Oct 24 16:50:21 EDT 2011
+#Tue Nov 22 15:22:09 CET 2011
osc.receiving.port=8020
osc.address.send=/fromTwitter
twitter.ConsumerSecret=q5ECt4fqWBmscfoMGNzpQXnp9TGt9W653m4zoA4sqY
twitter.AccessToken=
osc.address.recv=/toTwitter
twitter.followIDs=62130733
-osc.destination.host=localhost
+osc.destination.host=192.168.1.255
twitter.AccessTokenSecret=
twitter.ConsumerKey=0A8dJL19TWgqrKl6VgsiAg
-twitter.trackwords=\#OWS occupy
+twitter.trackwords=occupy \#OWS revolution
osc.destination.port=9000
@@ -25,7 +25,7 @@ void draw() {
//PImage b = loadImage("backgr.png");
background(backgr);
controlP5.draw();
- //delay(20);
+ delay(5);
}

0 comments on commit a4415d4

Please sign in to comment.