Find Out Who Has a Crush On You With CrushGram

July 01, 2011
Written by
Opinions expressed by Twilio contributors are their own

Twilio Bug Logo

CrushGram co-founders Kenneth and Henry
This is a guest post by Henry Tsai, co-founder of CrushGram.

“Crush grams” generally happen around Valentine’s Day when college students send anonymous messages written on Crush soda bottles to their crushes. We decided to bring back this tradition from our college days to the web with CrushGram.

CrushGram text message
At first, we wanted to do CrushGram by snail mail, but it was simply too slow. So we experimented with email, but our messages were being marked as spam. Finally, we realized SMS messages solved both problems of speed and noise. Twilio was the natural choice. The code examples were so easy to follow that it became a no brainer to purchase our own Twilio phone number right away.

For CrushGram, we only needed to send outbound SMS. We just took the code sample from Twilio SMS Quickstart: Sending Text Messages via the REST API and created the function below sendSMS($number, $message)

[code lang=”php”]
function sendSMS($number, $message) {
  // include the PHP TwilioRest library
  $ApiVersion = "2010-04-01";
  $AccountSid = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
  $AuthToken = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
  $twilioNumber = "xxx-xxx-xxx";
     $client = new TwilioRestClient($AccountSid, $AuthToken);

  // Send a new outgoinging SMS by POSTing to the SMS resource */
  $response =
      "POST", array(
      "To" => $number,
      "From" => $twilioNumber,
       "Body" => $message
   if($response->IsError) echo "Error: {$response->ErrorMessage}";

We then took this function and embedded it everywhere else that needed to send SMS, such as when someone inserts a crush with a name and number.

[code lang=”php”]
function insertCrush($fromNumber, $toNumber, $toFirstName = ”, $oneWord = ”) {
$conn = get_db_conn();

$sqlStr = sprintf(‘INSERT INTO crushes SET fromNumber = "%s",
toNumber = "%s", toFirstName = "%s", oneWord = "%s"’,

mysql_query($sqlStr, $conn);
if($oneWord != ”) $oneWord = ‘ with note: "’.$oneWord.’".’;
else $oneWord = ‘.’;
if(!checkMatch($fromNumber, $toNumber)) {
$message = ‘Hi ‘.$toFirstName.’! A secret admirer sent you a
crushgram’.$oneWord.’ Find out who at!’;
sendSMS($toNumber, $message);
} else {
$fromFirstName = userDetailsFromCell($fromNumber, ‘firstName’);
$message = ‘Congrats ‘.$toFirstName.’! Your crush,
‘.$fromFirstName.’, also has a crush on you.’;
sendSMS($toNumber, $message);
$message = ‘Congrats ‘.$fromFirstName.’! Your crush,
‘.$toFirstName.’, also has a crush on you.’;
sendSMS($fromNumber, $message);

The site took one night and four energy drinks to get off the ground. Besides Red Bulls, other technologies we used included LAMP stack and lots of JQuery on top of Twilio’s API. We also quickly integrated Facebook Likes, Super Rewards for offers, and PayPal.

Right now, we’re listening to our users to figure out where to go next. One thing we’ve been hearing is that people want the opportunity to anonymously message friends without it being romantic. We think there’s a lot to innovate in social relationships and text messaging: it’s real time, people always read their text messages, and it feels more personal — having someone’s number means you’re more than Facebook friends. Twilio makes achieving all of this a snap.

Thanks to Henry for taking the time to write about CrushGram! Have a social text messaging idea of your own? Get started with Twilio SMS for free.