SMS

TextMarks Lite is a free online service that allows for the sending and recieving of text messages on the regular mobile network. TextMarks allows anyone to register a keyword of their choosing and to utilize the shortcode 41411.

(I registered the leitv for demonstration purposes)

One of the great things about TextMarks is that you can have the service hit a script running on a remote server through a web request (HTTP).

Using this functionality as well as the ability to send SMS back you can allow mobile users to participate with programming.

To have my keyword hit a script that I am running on a webserver, I have to choose "Respond to a keyword with text from a webpage" when setting up the keyword with TextMarks:

Running a browser in full screen with video support and SMS overlays could be interesting:
An Example.

AJAX

AJAX stands for Asynchronous JavaScript and XML. Basically it is a means through JavaScript to get additional or dynamic content from a server without reloading a page. This is particularly useful when using a browser as the means for displaying content.

As you can see, in the code above, there is JavaScript that calls a function called "makeHttpRequest" which is defined in ajax.js. (In order to develop these types of applications, is probably helpful to download and place in the same directory as your HTML the ajax.js script.)

The "makeHttpRequest" function takes in two arguments, the first is what URL to hit and the second is what to do when you get a response from that URL. In this example, when a response comes in it calls the "ajax_return" function which takes care of updating the text in the "textsection" div.

The above code also includes some CSS to place the video and text. Learn more about CSS here: http://www.w3schools.com/css/. For the purposes of this class, you will probably want to pay particular attention to "position", "z-index", font size, font color, alignment and so on.

Of course, you can do so much more, either in JavaScript in the "ajax_return" function or in PHP on the server side.

AJAX Gotchas

One thing that you need to be concerned with when doing any type of AJAX is that the request through AJAX needs to come from the same server that page initially loaded from. In our case, itp.nyu.edu.. You can't load data from elsewhere without getting it from itp.nyu.edu in the end. Of course, you could have a PHP script make the request for data from elsewhere and return that data to the AJAX script.

More Complex

This example allows users to vote via SMS for which video they would like to watch.

What follows is the PHP that get's hit by Textmarks when a message comes in. It is almost exactly the same as the version in the previous example but instead of re-writing the file which contains the last message, it saves all of the messages (using the "append" method of fopen).

Here is the main page. This page via JavaScript/AJAX hits the above scrip periodically and get's the latest tally results. It then does some calculations and adjusts how the screen looks. All of this happens in the "ajax_return" function.