PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Mon Nov 18, 2019 5:14 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 46 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: Sending SMS messages
PostPosted: Sun Mar 30, 2003 9:35 pm 
Offline
Moderator
User avatar

Joined: Sat Apr 20, 2002 3:14 pm
Posts: 1416
Location: Dallas, TX
I was wondering how we could integrate PHP and SMS to send text messages to a specified phone number. Should I go through Sprint's "Developer program"?

A few sites have done the same thing... Example: http://www.send-a-text.net/

Any ideas?

_________________


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 31, 2003 12:30 am 
Offline
Moderator
User avatar

Joined: Sat Apr 20, 2002 3:14 pm
Posts: 1416
Location: Dallas, TX
I've whipped up a small php file that will allow the user to send text messages of 130 chars or less, to the desired phone number, and desired service.

Source:

Syntax: [ Download ] [ Hide ]
<html>

<body>

<font style=font-family:Verdana;font-size:12px;color:000000;>

<?



if ($_POST["action"] == "send") {

 // Sort through services

switch($_POST["service"]) {

  case 'att':

    $service = "mobile.att.net";

   break;

  case 'cingular':

    $service = "mycingular.com";

   break;

  case 'nextel':

    $service = "messaging.nextel.com";

   break;

  case 'qwest':

    $service = "qwestp.com";

   break;

  case 'sprintpcs':

    $service = "messaging.sprintpcs.com";

   break;

  case 't-mobile':

    $service = "tmomail.net";

   break;

  case 'verizon':

    $service = "vtext.com";

   break;

  case 'voicestream':

    $service = "voicestream.net";

   break;

}

      // Trim up a few variables

      $number = str_replace("(", "", $_POST["number"]);

      $number = str_replace(")", "", $number);

      $number = str_replace("-", "", $number);

      $number = str_replace(" ", "", $number);

      $number = eregi_replace("^[a-zA-Z]$", "", $number);

      $smsto = $number . "@" . $service;

  if (strlen($message) > 130) {

   echo "Message is too long. Try keeping the message under/exactly 130 characters.<p>\n\n";

  } else {

    mail($smsto, $subject, $message, "From: The xSMS service") or die("Unable to send your message. Please try again later.");

      // Record information into MySQL Database

      $time = time();

      @mysql_connect("localhost", "user", "pass");

      @mysql_select_db("php");

      mysql_query("INSERT INTO sms_messages (`number`,`service`,`email`,`message`,`time`) VALUES ('{$_POST["number"]}','{$_POST["service"]}','$smsto','{$_POST["message"]}','$time')");

    echo "Your message has been sent.<p>\n\n";

  }

}

?>

 <form method="POST" align=center action=<? echo $PHP_SELF; ?>>

 <input type=hidden name=action value=send>

 <table border=0 cellspacing=2 cellpadding=0 style=font-family:Verdana;font-size:12px;color:000000;>

  <tr><td><b>Message:</b></td><td valign="top"><textarea name=message rows=5 cols=18 wrap=no style=font-family:Verdana;font-size:12px;color:000000;></textarea></td></tr>

  <tr><td><b>Number:</b></td><td valign="top" align=left><input type="text" name=number style=font-family:Verdana;font-size:12px;color:000000; size=19></td></tr>

  <tr><td><b>Service:</b></td><td valign="top" align=left><select name=service style=font-family:Verdana;font-size:12px;color:000000;><option value="att">AT&T Wireless<option value="cingular">Cingular<option value="nextel">Nextel<option value="qwest">Qwest Wireless<option value="sprintpcs">Sprint PCS<option value="t-mobile">T-Mobile<option value="verizon">Verizon<option value="voicestream">VoiceStream</select></td></tr>

  <tr><td valign="top" align=left></td><td valign="top" align=left><INPUT TYPE="submit" width=84 height=15 border=0 value="Send Message" style=font-family:Verdana;font-size:12px;color:000000;></td></tr>

</table>

</form>

</font>

</body>

</html>


Edit: Updated service list

_________________


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 31, 2003 7:27 pm 
Offline
PHP Evangelist
User avatar

Joined: Tue Aug 13, 2002 3:35 pm
Posts: 3547
Location: Calgary, Canada
Very nice. I was just thinking send some variables to the local sites:

http://www.rogers.com/english/wireless/sendpcs.html
http://www.telusmobility.com/sendamessa ... sage.shtml
http://www.fido.ca/portal/home/quickMsg.jsp?lang=en

:) This is much easier. hmmm now i wonder how i can find out the exact service address for these...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 31, 2003 9:20 pm 
Offline
Moderator
User avatar

Joined: Sat Apr 20, 2002 3:14 pm
Posts: 1416
Location: Dallas, TX
There must be a list somewhere with area codes and first 3 letters of the 7 letter number that will determine it's service.

Anyway, I plan on making a little community type service for cell users, so they can login with their number + password (setup when registered their phone with my community), keep "buddies" (will set up a phonebook, listed by a nickname, so it's even easier to send SMS messages to your friends), history of your sent messages, etc...

What a good Weekend project. :)

_________________


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 01, 2003 7:09 pm 
Offline
PHP Evangelist
User avatar

Joined: Tue Aug 13, 2002 3:35 pm
Posts: 3547
Location: Calgary, Canada


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 01, 2003 8:17 pm 
Offline
Moderator
User avatar

Joined: Sat Apr 20, 2002 3:14 pm
Posts: 1416
Location: Dallas, TX

_________________


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 02, 2003 12:13 am 
Offline
PHP Evangelist
User avatar

Joined: Tue Aug 13, 2002 3:35 pm
Posts: 3547
Location: Calgary, Canada
Sounds good. :D


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 15, 2003 10:57 pm 
Offline
PHP Evangelist
User avatar

Joined: Tue Aug 13, 2002 3:35 pm
Posts: 3547
Location: Calgary, Canada


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 15, 2003 11:11 pm 
Offline
PHP Evangelist
User avatar

Joined: Tue Aug 13, 2002 3:35 pm
Posts: 3547
Location: Calgary, Canada


Top
 Profile  
 
 Post subject: nice idea
PostPosted: Fri May 16, 2003 6:54 am 
Offline
Forum Contributor
User avatar

Joined: Mon Apr 28, 2003 7:10 am
Posts: 215
Location: Leeds


Top
 Profile  
 
 Post subject: Re: nice idea
PostPosted: Thu Jun 05, 2003 6:26 pm 
Offline
PHP Evangelist
User avatar

Joined: Tue Aug 13, 2002 3:35 pm
Posts: 3547
Location: Calgary, Canada


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 05, 2003 7:24 pm 
Offline
Moderator
User avatar

Joined: Sat Apr 20, 2002 3:14 pm
Posts: 1416
Location: Dallas, TX
We could set up a one-line code that will SMS yourself whenever a visitor visit's your site. :D

_________________


Top
 Profile  
 
 Post subject: Re: nice idea
PostPosted: Thu Jun 12, 2003 4:42 pm 
Offline
Forum Newbie

Joined: Thu Jun 12, 2003 4:42 pm
Posts: 1
Location: Bournemouth, UK


Top
 Profile  
 
 Post subject: a stupid question .. ><
PostPosted: Mon May 17, 2004 8:59 am 
Offline
Forum Newbie

Joined: Mon May 17, 2004 8:59 am
Posts: 2
I think I should apologize for this stupid question first :P ,
I'm a newbie in working wif PHP,
i can't even open a php file,
how can i open it??
just direct double click it??
i did so but source code of that page showed,
i tried enable the IIS and open it at client site also get the same result,
what's wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 17, 2004 9:06 am 
Offline
Admin
User avatar

Joined: Wed Aug 13, 2003 7:02 am
Posts: 4522
Location: York, UK


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 46 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group