May 6, 2008
Using SMS Text Messages with Quartz Composer
Next week, I will be taking part in the Mobil/And workshop in ESADSE in Saint-Etienne, France. I was planning content for my speak during the workshop and came up with a rather cheap and robust way of using SMS text messages in Quartz Composer.

Previously, I had been able to come up with a hack that involved BluePhoneElite, AppleScript and iTunes to send SMS to Quartz Composer. I used this for example in the FF>> Media Festival last fall, but it was really awkward solution and you could only have the information of the latest message. So, I had to think of some better way.
This time around, I’m using the excellent Cocoa UltraSMS to send my SMS messages to a MySQL database. Then I’m using a small php-script to convert the database into an XML file which can be easily read and manipulated in Quartz Composer. Here’s how you do it:
WHAT DO YOU NEED
- Computer running Mac OSX (I’m on an early 2008 Macbook Pro)
- Mobile phone with bluetooth (I’m using Nokia 6103)
- Cocoa UltraSMS -software (it’s free)
- Quartz Composer
- Empty MySQL database
- Some PHP skills
1st STEP - Create the Database
Ok, let’s start. First of all, you need to create an empty MySQL database. For the purpose of this tutorial, I’m going to call my database sms_database.
2nd STEP - Cocoa UltraSMS
Then you need to download and install Cocoa UltraSMS. Setup your phone to connect with it and also insert the information of your database to the fields. Your settings will be different, of course.

After you click OK Cocoa UltraSMS will ask you if you want to create tables for your database. Click OK and and after that hit Start to connect to your phone. Now you can test the connection by sending yourself an SMS. The SMS In counter should increase and if you have Growl enabled you should also see the message in the Growl window.
3rd STEP - PHP lovin’
Now we need to somehow convert the information in the database to an XML file. I’m really far from being a PHP expert, but even I was able to do this, so if you have even a little bit of experience in PHP this shouldn’t be too hard. I used this tutorial to help me.
Here is the PHP code that you will need to upload to your server in order to make this work.
EDIT: As it seems to be almost impossible to paste any working code on Wordpress as the WYSIWYG editor f*#%s it all up, I’ve decided to upload the code as a separate file. Download the .txt file here, modify the database settings and rename it to whatevernameyoulike.php. (Can anyone point me to a Wordpress plugin that disables all the “intelligent” modifications the editor makes? I’ve tried a few and none of them work perfectly.)
Just upload the .php file to your server and point our browser to the url. It will look something like this http://originalhamsters.com/sms/sms.php
You might have noticed the strange lines in the php code like this one
$row['message'] = str_replace(”|”, “ö”, $row['message']);
I’m using those just to display the Scandinavian letters properly. This really can’t be the best solution to do that, but it works for now, unless you want to use smilies that is. I’ll have to see how and where I should change the encoding settings to get this display properly without this hack.
4th STEP - Quartz Composer
Now for the easy part. In QC you need to just connect the XML Downloader to a couple of Structure Index Member -patches, modify the XML location to be the URL of your .php file and you are all set. Download here a simple .qtz file that just displays the latest message.

5th STEP - What next?
Now it’s just a matter of what to do with the data you receive from the messages. I have a bunch of different applications in mind. You will probably hear from them pretty soon. I just got this thing working today, so I haven’t had the time to test all the possibilities.
Of course, this same technique can be used to access SMS data from various other applications that can read XML files like Flash, Processing etc. I just used Quartz Composer as an example because it’s the environment I’m most comfortable with.
That’s it. Hopefully this is helpful to someone. I’ve seen many interactive installations where SMS messages are used, but I haven’t seen good documentation on how to do it anywhere. Feel free to comment here or email me if you have any improvements or questions.

I had to change the coda a little bit. I had a limitation of only 30 tables in the php. The code above is now correct.
Comment by Waxtastic — May 7, 2008 @ 11:37
This looks great man. Haven´t got the time to check it out yet, but it would be very nice to test out in a future gigg/project. I will bookmark the page and get ready to use some free time to get this up and running for my self. Thanx!!
Comment by ernst — May 26, 2008 @ 16:08
great but with my poor php knowledge i couldn´t get the thing to work… getting this error on the php file…
Parse error: parse error in /home/httpd/vhosts/designanstalt.net/httpdocs/sms/sms.php on line 16
any idea?
greetings
amon
Comment by amon robe — July 2, 2008 @ 12:02
hmm.. I’m really a noobie in php also so I can’t really help you. I got that file working with the help of some tutorials and a bunch of luck.
I had a lot of problems trying to copy the code as it should be on this blog because Wordpress always tries to mess with your text thinking it knows what I want to do. So it actually is possible that the code I posted here is not working properly and the Wordpress text editor has removed some of the code. I’ll have to check if that’s the case.
Has anyone actually used this tutorial successfully?
Comment by Waxtastic — July 5, 2008 @ 20:35
OK. That seemed to be what was wrong. The WYSIWYG Wordpress editor removed a couple of backward slashes from the code. I missed those and never actually tested the code that showed on the blog post.
It’s fixed now.
Thanks a lot for pointing this out Amon!
Comment by Waxtastic — July 5, 2008 @ 21:01
Thanks for this works great a really, really useful solution so thank you so much for sharing.
Steve
Comment by steve Holmes — July 6, 2008 @ 21:08
sorry, i dont get it. i need mysql hosting for ultrasms and additional php hosting for the php file? may i use my .mac account for the php file? could this be done internally on my mbp to avoid port number conflicts when i’m not at home?
Comment by bogga — July 7, 2008 @ 3:38
You can do this all in localhost also. I just found it easier to use my webserver. I haven’t really tested this, because my non-s60-phone disappeared/was stolen and Cocoa UltraSMS only works with non-s60 phones.
Another option, if you have an s60 phone - is to use Mercurio: http://jmarinez.typepad.com/blog/
Comment by Waxtastic — July 7, 2008 @ 12:41
OK. Just tested this. Seems to work perfectly with localhost.
Setting up MySQL in Leopard is a little bit of a hassle, or at least it was a few months ago when I did it, but there’s plenty of instructions if you google it.
Here is a good tutorial on how to work with php in localhost. http://www.procata.com/blog/archives/2007/10/28/working-with-php-5-in-mac-os-x-105/
Really helpful tool in creating and modifying databases: http://yoursql.ludit.it/
Comment by Waxtastic — July 7, 2008 @ 13:27
i set it up on localhost too. thanks a lot! i’m getting errors though, - i’m norwegian, - scandinavian letters æ,ø,å, - you seem to have removed the lines of code that deal with those. could you mail me those lines? they are not identical to swedish ä, ö, å though
Comment by bogga — July 8, 2008 @ 16:30
Cocoa UltraSMS is pretty flawed as the encoding doesn’t recognize other than English characters.
You have to manually add the replace codes in the php file. Here is a table that shows the correct decimal codes you need to use http://msdn.microsoft.com/en-us/library/ms537495(VS.85).aspx
Comment by Waxtastic — July 8, 2008 @ 17:33