There has been a crucial update. This version doesn’t work anymore. Update available here
———————————————————————————————————–
First off, a big thanks to Matthew Eddey for helping with the Ruby script and Twitter API. Also to all the people that helped along the way.
This should work on Max 5 and Mac OS and Window.
how to send a tweet directly from Max/MSP
I used the Ruby programming language to access Twitter’s API. To use Ruby within Max/MSP you need to download the [ajm.ruby] external by Adam Murray. After downloading, follow the “INSTALL.txt” instructions to correctly install it.
This is not necessary, but if you want to count the remaining characters you need to download the [strlen] external by Jasch and put it in Max’s search path.
Finally, download the MaxToTwitter patch.
That should be it, enjoy sending tweets from Max!
If you use it in a project don’t be shy to include my name or link back to here







Just checked Max 5 on Windows, works great! Now I can tweet on stage w/o leaving Max5!! Keep up the good work!
Awesome! Thanks for letting me know. I’ll update the post.
This is rad. Glad to see my software is being put to cool uses! If you run into any issues with ajm.ruby or have thoughts on ways to enhance it, don’t hesitate to drop me a line. I’ll be releasing an update soon-ish with a new JRuby version that is faster and more efficient than the current version.
Adam, thanks so much for making ajm.ruby available!!! Let me know when the update is ready, and I’ll update TAS. And thanks for the comment.
thanks, huge help
ruby the best!!!
I’m trying to use this patch, but it doesn’t seem to be working – I keep getting the error message
ajm.ruby: could not evaluate: $message = whatever
However, I tried the Tweet-A-Sound app and I am able to tweet from that just fine.. Is there any difference between the standalone patch and the patch you use within tweet-a-sound?
Any help would be much appreciated.
Thanks a lot
Hi Aaron, can you give a bit more details? What setup are you on? Is the problem happening once you build a standalone or through Max? Are you sure you installed [ajm.ruby] correctly? Maybe open the [ajm.ruby] help patch and test it?
It’s working with me as a patch. I’m on Snow Leopard, it also worked on Leopard. However, I’ve been working on an other application, which uses a similar setup and is not working when building standalones. It might be an issue when using java in Max on Snow Leopard, I need to email Cycling ’74 for more info.
I’m running the patch through max 5.1 on snow leopard.. haven’t tried making a standalone. ajm.ruby seems to be installed correctly, the help patches for it work and everything. Everything seems to run okay but it doesn’t like the “$message = x” message.. Strange
umm… same as me. I’m not sure then. It could be that when you type it is not entered into the message boxes. Maybe try type your message and password and username and then click again on each and hit enter to make sure they get put into the code. It should look like: [$message = yourmessage]
If you look into the Twitter subpatch, you should see all the info you put into the text boxes being entered into the red message boxes. Did you try change the message manually?
hi Aaron and Andrew,
I had same thing but i figured out what was happening. Maybe $message has to have double-quated text. But when the input text is just one word like “whatever”, textedit object outputs without ” ” between the word. 2 more words like “whatever text” will be output as , so you can try with 2 more words!
hi Aaron and Andrew,
I had same thing but i figured out what was happening. Maybe $message has to have double-quated text. But when the input text is just one word like “whatever”, textedit object outputs *text whatever* without ” ” between the word. 2 more words like “whatever text” will be output as *text “whatever text”*, so you can try with 2 more words!
Haha, yes. I remember now, totally forgot about that. It doesn’t work with just one word… It didn’t matter for me because I always use it with more than one word.
if you want to be able to use it with just one word, you can probably just use [sprintf] to add a space before or after.
Hey guys, I get a funky message when trying to send:
ajm.ruby: could not evaluate: require ‘net/http’ require ‘uri’ $url = $url.delete(‘ ‘) puts $url res = Net::HTTP.post_form(URI.parse($url), {‘status’ => $message}) if res.code == ’200′ then out1(Sent!) else out1(Error! (#{res.code}: #{res.message})) end
Any ideas?
Thanks, this is a crazy patch
I get this message “could not evaluate” from the ajm.ruby external every time I try to send it anything, even from the help files… Troublesome.
Hi Joe, sorry for the delay in replying. Been very busy and with limited access to internet. I don’t have time to look at it in detail, but off the top of my head, there are a few things that could be doing this.
Make sure that you have at least 2 words in your message, if not just add a space. It’s a stupid bug that I could fix (check the comment above) but it will be for some other day.
Are you sure you installed the [ajm.ruby] stuff correctly? That could also be the problem.
Try these suggestions, and if it still doesn’t work don’t hesitate to message again with what OS you’re using.
Hope you get it working
Thanks Andrew,
Actually I’ve been emailing with Adam and I think its an issue with the newest update of Max and the ruby object. Hopefully he’ll have some time to fix it, and it gets resolved, but for now, i think one must remain on the previous version of Max to get this to work.
Thanks again!
Oh, good to know! Thanks for telling me. cause I need some of the ajm objects for something I’m soon compiling… so I won’t update! Curious to see what you’re up to if you wanna share.
Just put up some documentation of a project I did using your patch, generating gibberish tweets through a needlessly complex text-to-speech-to-text process. There’s a page for it up at http://www.aaronoppenheim.com/?page_id=241
Thanks muchly for the work you did. I had to downgrade to Max 5.08 to get it running though, hopefully ajm.ruby will be updated soon.
@Aaron cool project. Thanks for sharing it. I’ve been waiting to update Max/MSP for that exact reason. I hope Adam updates it soon.
Thanks for your idea!
Hello I’woudlike to know if I must modify anything in these script to send tweet
require ‘net/http’
require ‘uri’
$url = $url.delete(‘ ‘)
puts $url
res = Net::HTTP.post_form(URI.parse($url),
{‘status’ => $message})
if res.code == ’200′ then
out1(“Sent!”)
else
out1(“Error! (#{res.code}: #{res.message})”)
end
I see in a max window:
ajm.ruby: could not evaluate: require ‘net/http’ require ‘uri’ $url = $url.delete(‘ ‘) puts $url res = Net::HTTP.post_form(URI.parse($url), {‘status’ => $message}) if res.code == ’200′ then out1(Sent!) else out1(Error! (#{res.code}: #{res.message})) end
@Baudry The script should work. Apparently the latest update of Max/MSP doesn’t work with [ajm.ruby], which might be the cause of your issues. Try downgrading Max and see if that fixes the issue. I’m on version 5.1.1 and it works.
the ajm.ruby object has been updated (download here: http://groups.google.com/group/ajm-objects)
the error @baudry gave remains the same
any suggestions anyone?
ajm.ruby: could not evaluate: require ‘net/http’ require ‘uri’ $url = $url.delete(‘ ‘) puts $url res = Net::HTTP.post_form(URI.parse($url), {‘status’ => $message}) if res.code == ’200′ then out1(Sent!) else out1(Error! (#{res.code}: #{res.message})) end
in the first line it says ‘uri’ shouldn’t that be url?
Hey Sunnys, thanks for pointing that out. URI is fine though, that’s not the issue. I think the issue is to do with Snow Leopard’s 64bit java and ajm.ruby not being updated for that. Not 100% sure though. Didn’t the ajm.objects where updated, good to know. Pity that doesn’t solve the issue.
one of the main reasons i can’t downgrade to 5.08 is it’s lack of maxforlive functionality which was comes only in 5.1.1 and above and i wanna tweet from within ableton!
Hey Andrew,
First of all, thank you!
Now, I have this problem with the patch. It doesn’t send any tweets and this is what it gets printed on the max window:
==> http:// [username] : [password] @twitter.com/statuses/update.json
==> [message]
http://username:password@twitter.com/statuses/update.json
==> nil
OBS: 1. in the real situation there are words in [ ] brackets accordingly.
2. mind the space between username and password and @twitter.com the first time it prints and the fact that they are not present anymore the second time around. Is it normal? I just pressed once!
Any advice is truly appreciated!
it’s a pleasure. Sorry it’s not working for you. May I ask what version of [ajm.ruby] you have? Cause if you’ve updated to the 0.9 ones that are in beta, then you will have back compatibility issues. He changed a lot. I would have to go in and figure it all out from his change log, which I’ll start working on now and see how I come along.
Hey Andrew,
I am using 0.8.8. Is that a problem as well? Can you tell me if what is printed in my max window is normal? Do you have the same thing printed in your max window? I wanted to know if it is a problem within max or with twitter.
Which one of these sentences is right? http:// [username] : [password] @twitter.com/statuses/update.json or http://username:password@twitter.com/statuses/update.json
I am really really new in twitter so I have no clue!
thank you so much!
Hey Ygreq,
Using 0.8.8 won’t be the problem. I think Twitter changed their API to OAuth, and I was using REST. So I’ll see what I can do, and if it’s not too time consuming, I will update it. Sorry about that.
Regarding the spaces, I can’t remember why, but I do know that it was working, so the reason why it’s not is because of the change in their API. I think ajm.ruby did something with the spaces, which is why I added them. I can’t check anything cause I’ve updated my ajm.ruby to 0.9 and it’s all different now… Really sorry about this.
Stay tuned, I’ll try post an update.
ok so the whole idea is that right now your patch doesn’t work as well because of twitter changing the way in which we can interact with it.
Roger! Will wait for an update!
Thank you very much!!
yip, sorry! + I’ll need to update the patch to work with the new ajm.ruby object. Sorry!
Hi There,
This looks like an awesome little project, I was just wondering if there was an easy way of reading IN to maxMSP the latest tweets from the live feed using a similar method? Its for a little project i’m working on! Any help would be much appreciated!
Sam
Hey Sam, thanks for the comment. First off, this method is obsolete and doesn’t work anymore. Twitter changed their API, someone helped me updating it, and although it’s ready I will only be able to post it in December as I’m overseas on a job at the moment. We haven’t worked on accessing live feeds though, only for posting. Depending on time and interest, we might get that working. We’ll see.
it’s a good hint to compose music.
thanks a lot andrew. and thanks for the creative commons too.
sorry for my broken english. i’m italian.
awesome work. I skimmed the posts and did not find an answer to the following:
Is there a way to go in reverse with Max & Twitter? I’d like to display tweets inside a max patch. I know I can do this with a web view object, but was wondering if here was another way.
I’m planning a performance where the audience and performers interact via twitter in real time.
thanks
Steve
Hey Steve,
Actually you’re in luck! Mathias and I are soon gonna be releasing a BIG update where you’ll be able to receive tweets (plus much more). Can you be patient? Maybe a few weeks? If your performance is soon, then we can out something together for you… But it’s easier if you can wait for the official update.
I can wait a few weeks. Performance is in Feb 2012. I can’t wait to get the update and use it. I’ll make sure to give you a shout for your work and post video when I get it.
thanks, this is awesome!!
Steve
Finally got around to installing all of this. I cannot get it to work. Max returns several errors.
newobj: strlen: No such object
text: bad number
sdjphotos: bad number
ajm.ruby doesn’t understand $url
ajm.ruby doesn’t understand $message
ajm.ruby: could not evaluate: require ‘net/http’
require ‘uri’
$url = $url.delete(‘ ‘)
puts $url
res = Net::HTTP.post_form(URI.parse($url),
{‘status’ => $message})
if res.code == ’200′ then
out1(“Sent!”)
else
out1(“Error! (#{res.code}: #{res.message})”)
end
:4: undefined method `delete’ for nil:NilClass (NoMethodError)
I followed the install instructions but am having issues. Perhaps you can help?
Thanks
Steve
You’re trying with an old version. There’s been a crucial update since. Twitter changed their API, and many other changes. Here’s the update: http://www.soundplusdesign.com/?p=4213
I will put a little note at the top of this post pointing in the right direction.
Andrew, this patch is wonderful. Was wondering if there is a simple way to allow others to tweet to their account from the patch I build. I know the older version of this patch had a “username” and “password” option to decide where the tweet would end up. Is there a way to implement this function into the current patch? Cheers.
Thanks, John. Actually the whole reason for this update is that Twitter changed their API and now you have to go through an authorization system. It’s such a mission, but there’s no workaround (that I’m aware of). Sorry!