1 Table (ID,CODE,SELECTED)

1 Numerical Sequence to generate primary key (ID)

1 Trigger before insert record that will get the ID value and append a random number to the CODE column

1 public procedure to retrieve the code (where selected = 1)

1 public procedure to update the code once is used and generate a new one.

I realized that someone with mischievous intentions could just tweet-spam the @Tweetfortreat account (or less likely someone could text or call my Twilio number numerous times) and I would end up with tons of candy on the floor.Instead, I created a REST web service using of course my favorite web development tool, Oracle Application Express http://apex.oracle.com/ , to make sure a unique and random code was generated each time candy drop request was made from text, call or Twitter.The REST application is really simple and I recognize it can also be created using any other technologies such as LAMP or even a GCI, or Perl application.Application Objects:So I ended up with these two URL

http:/my.apexserver.com/pls/apex/getcode

http:/my.apexserver.com/pls/apex/updatecode?code=XXXX



*If you would like to implement something with a static file instead, I would recommend using http://www.random.org/clients/http/ to get a random number and store it in file, memory, or even the arduino itself.