Loading...
Logo
Processing Forum
martinmc's Profile
2 Posts
4 Responses
0 Followers

Activity Trend

Last 30 days
Show:
Private Message
    Hi,

    Has anybody any ideas on how to reply to a tweet using Twitter4j?

    I want to be able for search for tweets, and when I find these tweets, I want to be able to reply to a particular tweet. 

    Say I'm searching for tweets with the work 'ProcessingForum'. I search for these tweets, and get the ScreenName by using getScreenName();. I can send tweets to anybody who has tweeted something with the string 'ProcessingForum', but I want to be able to reply to the particular tweet that has mentioned 'ProcessingFroum'.

    Any Ideas?

    Some code below that shows how I'm doing it so far

    1. String sendto = ""; ///////string to store the ScreenName

    2. void setup() {
    3.   
    4.   size(100,100);
    5.   background(0);
    6.   
    7.   connectTwitter();
    8.   getTimeline();         //gets tweets from my timeline
    9.   getSearchTweets();   //gets any tweets with the defined string ///get the screen name before I send the tweet\\\\\
    10.   sendTweet("@"+ sendto + " You just tweeted about arsejesustweeting, you pup! (attempt #5)");
    11.   
    12. }



    13. void getSearchTweets() {  //search for all tweets

    14.   String queryStr = "ProcessingForum";

    15.   try {
    16.     Query query = new Query(queryStr);    
    17.     query.count(10); // Get 10 of the 100 search results  
    18.     QueryResult result = twitter.search(query);    
    19.     ArrayList tweets = (ArrayList) result.getTweets();    

    20.     for (int i=0; i<tweets.size(); i++) {
    21.       //Tweet t = (Tweet)tweets.get(i);
    22.       //String user = t.getFromUser();
    23.       //String msg = t.getText();
    24.       Status t=(Status) tweets.get(i);
    25.       User u=(User) t.getUser();
    26.       String user=u.getName();
    27.       String scrName=u.getScreenName(); //////////gets the screen name\\\\\\\\\\\
    28.       long id=u.getId();
    29.       String msg = t.getText();
    30.       String rply = t.getInReplyToScreenName();
    31.       
    32.       Date d = t.getCreatedAt();
    33.       theSearchTweets[i] = msg.substring(queryStr.length()+1);
    34.       println("Tweet by " + scrName + " at " + d + ": " + msg);
    35.       println(theSearchTweets[i]);
    36.       println("In reply to this Screen Name" + rply);
    37.       
    38.       sendto = scrName;
    39.     }

    40.   } catch (TwitterException e) {    
    41.     println("Search tweets: " + e);  
    42.   }

    43. }
    Hi, I'm trying to display two Strings of text along two different curves in a sketch. 

    I'm bringing tweets in from an excel sheet thats 100 rows in length, and I want the first 50 to display off/around one circle and the next fifty to display off/around a second circle. I can do the first fifty alright, but I can't get the second lot to display around the second ellipse that I've drawn.

    The code I've included is a slimmed down version of the code that I'm working with (the code I'm working with is a bit messy and long) but if I get it working on a basic level I can transfer it over. 

    Any and all help will be greatly appreciated! 
    Martin
    1. // The message to be displayed
    2. String message = "text";
    3. String message2 = "aaaa";
    4. PFont f;
    5. // The radius of a circle
    6. float r = 100;
    7. float q = r*2;

    8. float r2 = 100;
    9. float q2 = r2*2;

    10. void setup() {
    11.   size(800, 800);
    12.   f = createFont("Georgia",40,true);
    13.   textFont(f);
    14.   // The text must be centered!
    15.   textAlign(CENTER);
    16.   smooth();
    17. }

    18. void draw() {
    19.   background(255);

    20.   // Start in the center and draw the circle
    21.   translate(width / 2, height / 2);
    22.   noFill();
    23.   stroke(0);
    24.   ellipse(00, 00, r*2, r*2);

    25.   ellipse (100, 50, r2*2, r2*2);
    26.   
    27.   // We must keep track of our position along the curve
    28.   float arclength = 0;
    29.   float arclength2 = 0;

    30.     // Instead of a constant width, we check the width of each character.
    31.     //char currentChar = message.charAt(i);
    32.     float w = textWidth(message);
    33.     float w2 = textWidth(message2);
    34.     
    35.     // Each box is centered so we move half the width
    36.     arclength += w/2;
    37.     arclength += w2/2;
    38.     // Angle in radians is the arclength divided by the radius
    39.     // Starting on the left side of the circle by adding PI
    40.     float theta = PI + arclength / r;   
    41.     float theta2 = PI + arclength2 / r2;   

    42.     pushMatrix();
    43.     // Polar to cartesian coordinate conversion
    44.     translate(r*cos(theta), r*sin(theta));
    45.     translate(r2*cos(theta2), r2*sin(theta2));
    46.     // Rotate the box
    47.     rotate(theta+PI/1); // rotation is offset by 90 degrees
    48.     rotate(theta2+PI/1);
    49.     // Display the character
    50.     fill(0);
    51.     text(message,q,0);
    52.     text(message2,q2,0);
    53.     popMatrix();
    54.     // Move halfway again
    55.     arclength += w/2;
    56.     arclength += w2/2;
    57.   //}
    58. }