Thanks for your help. We've received your bug report.

Register for a C74 account and join an active community of artists and creatives. Post on forums and add your projects and tools to our growing showcase.

Create an Account

Searchtweet – Design patches that respond to twitter posts.

by

Here is a tool that will allow generating max patches that respond to twitter posts. I wrote this for an installation project and wanted to share.

Searchtweet.class is a mxj external that searches twitter with a given keyword and returns a desired maximum number of most recent posts, with username, date and twitter text body routed to separate outlets. The object returns a specified number of most recent twitter posts that contain a given keyword, #hashtag, or @usertag.

Searchtweet uses the twitter4j library (http://twitter4j.org) programmed by Yusuke Yamamoto.

Cheers,
Gokce Kinayoglu

DISCUSSION

12 Comments

bennyfromtheblock says:

This has got me thinking! :)

tom zic says:

This is fantastic. Thank you.

RT White says:

Excellent object and tool! Forgive my naivete as the world of APIs is pretty new to me, but is there a way to limit the output of this device to a single language? The patch I’m working on is mostly pertinent in English.

Thanks for any help.

Gokce says:

Hi RT, and all,
The plugin works using the basic search functionality of the twitter API. I do not know if there is a way to limit searches based on country or language through specific search keywords.
Also, the twit4j offers a push-based update functionality which I did not implement in this plugin. If there are any exciting projects that needs that kind of a more “realtime” update feel free to contact me in person or here.

RT White says:

Thank you Gokce! I will let you know if I get anything interesting working.

David Benson says:

Hey all,

Just for a clarification, if you are using the standard search parameters on Twitter you can search by language and by region. If you are using the Twitter Streaming API, however, the query language is different. I have yet to dig into this patch, but I wanted to see if I could be of service.

For the standard search terms, using lang:en should limit your searches to english only.

For geolocation use: geocode:40.7484918,-73.98428659999999,25km. You will need to use a third party service to determine the Latitude and Longitude of your location (The one I posed is Manhattan) and you can use the km parameter to alter the distance.

I like to use http://geocoder.us/ for finding a latitude and longitude. Just enter an address and it should output what you want.

Hopefully that helps a little to answer your question, @Gokce.

Gokce says:

Thanks for the information David! This is amazing.

The search parameters indeed work well with the script! There is a small trick. Max will interpret the commas in the message as separators. The message sent to the script needs to be formatted as shown below with backslashes before each comma, such as:

search geocode:40.748433\,-73.985656\,1km 1

Put that in a message box and wire it to the mxj directly. (Do not use the search box in the example patch.) This should give the most recent tweet sent from an area within 1km radius around the Empire State Building in New York. Tested, and here’s the result I received:

“fangirlDANosaur”
“RT @danisnotonfire: I’m currently having that classic tourist fangirl moment where I realise I know all the buildings in Manhattan from every movie/game ever. ”

Looks like she is in New York. Exciting! Now go play!

Gokce

Thierry says:

Hi David and Gokce,

Thanks for your precisions about language filtering and geocode. I would like to filter the tweets according to their language. But, as “search geocode:40.748433\,-73.985656\,1km 1″ works perfectly for me, “search voyage lang:fr 1″ returns the following errors :

java.lang.UnsupportedOperationException: does not contain an int
at com.cycling74.max.Atom.getInt(Atom.java:572)
at searchtweet.search(searchtweet.java:34)

Did I miss something ?
Thanks a lot if you would have an idea…
-Thierry

PS: Gokce: I left a question on your FB page about language filtering, before having found this page, sorry :)

Thierry says:

Hi David and Gokce,

I finally found the right syntax to filter by language, which is: search “voyage lang:fr” 10
It needed quotes.
Thanks, Best
-Thierry

KAIBE says:

Hi Gotkce and all, is there any advice you can give me on a similar kind of thing I’m doing here? http://cycling74.com/forums/topic.php?id=47084

Gokce says:

Hi Kaibe,

I suggest you to load the plugin and play with it before starting out with your project. Once you are able to get the text output that you need from searchtweet, the rest is figuring out how to “parse” it. There are several functions that does exactly that in MSP and there are also some external libraries for string parsing and search. Good luck!

Gokce

DRKOSS says:

Super cool – thanks for posting!

Leave a Reply