SMS from web application [closed]

I just want to send SMS from my web application in PHP. Can anyone tell me how to do this? What all things I need to do for this?


Solution 1:

I don't know if this applies to you, but what I have done many times to save myself the money is ask the user in his profile what his carrier is, then tried matching it with this list. Essentially, many/most carriers have an email address connected to a phone number that will easily let you send texts to the number. For example, if you have ATT and your phone number is 786-262-8344, an email to [email protected] will send you a text message with the subject/body of the email, free of charge. This technique will pretty much cover all of your US users for free. Obviously, depending on the needs of your application this may not be possible/adequate/desired, but it is an option to be aware of.

Solution 2:

Your main option for sending SMS messages is using an existing SMS provider. In my experience (which is extensive with SMS messaging web applications), you will often find that negotiating with different providers is the best way to get the best deal for your application.

Different providers often offer different services, and different features. My favourite provider, and indeed, the one that has happily negotiated with me for lower rates in the past, is TM4B (http://www.tm4b.com). These guys have excellent rates, cover a huge proportion of the globe, and have excellent customer service.

Below is some code extracted (and some parts obfuscated) from one of my live web applications, for sending a simple message via their API:

require_once("tm4b.lib.php");
$smsEngine = new tm4b();

// Prepare the array for sending
$smsRequest["username"] = "YOURUNAME";
$smsRequest["password"] = "YOURPWORD";
$smsRequest["to"] = "+441234554443";
$smsRequest["from"] = "ME!";
$smsRequest["msg"] = "Hello, test message!";

// Do the actual sending
$smsResult = $smsEngine->ClientAPI($smsRequest);

// Check the result
if( $smsResult['status'] == "ok" ) {
    print "Message sent!";
} else {
    print "Message not sent.";
}

Many other providers that I've used in the past, have very similar interfaces, and all are really competitive when it comes to pricing. You simply have to look around for a provider that suits your needs.

In regard to cost, you're looking at prices ranging from a few pence/cents for most Western countries (prices are a little bit higher for most third-world countries, though, so beware). Most providers you will have to pay in bulk, if you want decent rates from them, but they'll often negotiate with you for 'smaller-than-usual' batches. Most providers do offer a post-pay option, but only when you've successfully completed a few transactions with them... others offer it from the start, but the prices are extortionate.