Friday, March 20, 2009

Welcome to the Media Scripting 'blog

This 'blog will be the repository of computing-related ramblings by Samuel A. Rebelsky. Many of the posts will be related to my primary project, Media Scripting (interactive scripting of media applications and other aplications). Others will be about other topics in computer science, programming, or teaching of computer science.

A Hack: Web-based Texting to AT&T Phones

So, Michelle and I bought iPhones yesterday. While we're having fun with them, we did notice a problem: Our old phones were on Sprint, and Sprint provides a Web-based interface for sending text messages. AT&T seems to want you to log in to their system to send text messages. Since Michelle's work needs to text her regularly, that didn't seem to be a good solution.

Fortunately, AT&T does provide email-based texting (1234567890@txt.att.net). So, I taught myself some PHP, built a small Web interface to the PHP email function, and, voila, her work can now text to her. All in under an hour of time.

The script is appended. The HTML-based UI should be obvious. Comments are appreciated.
<?php
$phone = $_GET['phone'];
if (!$phone)
{
echo 'No phone number specified.';
exit(1);
}
$to = "$phone@txt.att.net";

$subject = $_GET['subject'];
$body = $_GET['body'];

if (!$body)
{
echo 'No body specified.';
exit (1);
}

$headers = "From: $to";

$mail_sent = @mail( $to, $subject, $body, $headers );
echo $mail_sent ? "Message sent" : "Message failed";
?>