SMS from web application

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

+59
php sms
Jan 11 '09 at 13:42
source share
21 answers

I do not know if this applies to you, but what I have done many times to save money, asks the user in his profile what he has, and then tried to match it with this list . In fact, many / most carriers have an email address associated with a phone number that will easily allow you to send texts to a number. For example, if you have ATT and your phone number is 786-262-8344, an email to 7682628344@txt.att.net will send you a text message with the subject / body of the email for free. This method 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 / desirable, but it is an option to be aware of.

+48
Jan 11 '09 at 16:54
source share

Your main option for sending SMS messages is to use an existing SMS provider. In my experience (which is extensive with web-based SMS messaging 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 functions. My favorite provider, and indeed, the one who happily negotiated lower rates with me in the past, is TM4B ( http://www.tm4b.com ). These guys have great rates, cover a huge share of the globe and have excellent customer service.

Below is a snippet of code (and some parts, confusing) from one of my live web applications to send a simple message through 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 have used in the past have very similar interfaces, and they are all really competitive when it comes to pricing. You just need to look back at the provider that suits your needs.

As for the cost, you look at prices from a few pence / cents for most Western countries (prices are slightly higher for most third world countries, though, be careful). Most providers will have to pay in bulk if you want to get decent bids from them, but they will often negotiate with you for "smaller than usual" parties. Most providers offer the option after payment, but only when you have successfully completed several transactions with them ... others offer it from the very beginning, but the price is extortion.

+26
Jan 11 '09 at 14:36
source share

Send only but cheap and easy

The easiest way is, of course, to use the email hacking that @ Paolo Bergantino mentioned above. It is easy to ask your users to enter their phone number and select their operator from the list. It is also easy, on absolutely any development platform, to send emails when you have user information.

There are two very important limitations that I have discovered with this approach:

  • Firstly, mobile operators all prioritize SMS messages sent through their mail gateways below other SMS traffic. Probably because they do not receive payment for them. Do not use this method if it is important for you to minimize the delay.
  • Secondly, especially in this modern era of portable telephone numbers, users will switch between operators from time to time and will almost certainly forget to tell you. If you need to reliably deliver SMS messages to the same people in a year or two, this method will fail.

Send and receive for cheap

If you are trying to configure your site to send and receive SMS messages on a budget, you can use a service such as TextMarks . TextMarks allows you to choose a keyword for your service that allows users to send you messages via the common TextMarks short code, 41411. The catch is that they leave 20 characters in each message for short advertisements to pay for their services.

Professional quality

If you require low latency, high reliability and lack of advertising, you will have to go through the SMS aggregator to a large extent, if you are not large enough to negotiate with each carrier individually.

The biggest thing I found to keep track of SMS aggregators is that many of them are really set up to be marketing companies, not applications - they really don't understand using SMS as a channel through which users can interact with service providers. I found that agents who use the phrase “your campaign” rather than “your application” are the worst offenders. Stay away from them and find an aggregator that understands your needs as an application developer.

+12
Feb 26 '09 at 5:47
source share

Twilio recently released an API for sending SMS messages . Api is a fairly simple, basic REST interface for sending SMS , and post returns a document for reply .

+11
Mar 25 '10 at 13:07
source share

Hi, my name is Jarod and I work for Twilio.com, so I'm a bit biased. But with that being said, it's incredibly easy to send SMS from your PHP web application using the Twilio REST API . Here is a simple example:

 <?php // Get the PHP helper library from twilio.com/docs/php/install require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library // Your Account Sid and Auth Token from twilio.com/user/account $sid = "{{ account_sid }}"; $token = "{{ auth_token }}"; $client = new Services_Twilio($sid, $token); $client->account->messages->sendMessage("+14158141829", "+14159352345", "Hi Shyju, Sorry it took me so long to get back to you. <3 The Internet."); 
+8
Jan 13 '14 at 22:24
source share

To do this, we use a commercial solution called TextAnywhere .

For a small fee (a few pence per SMS) they give you a web service (plus an API for .NET, ASP, Java, C ++, etc.). It is easy and works, although it is not free.

At its most basic, it is as simple as making a URL request with the message number and text in QueryString, and their server will do the rest for you.

+4
Jan 11 '09 at 14:24
source share

If you know the carrier, you are golden. Most of them have email gateways. If not, you can use the Clickatell API, which costs around $ 0.04 per message. Now I am looking at a hack where you will use a GSM modem and an individual cell phone plan with an unlimited number of SMS messages. It can save a lot of money if it works.

+4
Jun 30 '09 at 21:16
source share

If you want to invest in an Android smartphone, you can set up your own SMS gateway, which in the end will be cheaper.

I use SMS GATEWAY ME , which is a free Android application, you can send a message as follows:

 $URL = "http://v2.smsgateway.me/API/Send/Single.php"; $postdata = http_build_query( array( 'Username' => "foo@bar.co.uk", 'Password' => "password", 'Number' => "+447791064782", 'Message' => "Hello World!", ) ); $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata)); $context = stream_context_create($opts); $result = file_get_contents($URL, false, $context); 

There is documentation on their site that tells how to receive incoming messages.

+3
Dec 31 '14 at 16:42
source share

If you need a reliable way to send a large number of SMS messages, you should look for an SMS service provider that acts as a web gateway for SMS. In this case, there will be an http-based interface that allows you to send SMS by calling the URL and passing the recipient and message as parameters.

+2
Jan 11 '09 at 14:18
source share

dktext not only allows you to send bult text messages to requesting clients, but integration with Google Voice will soon be enabled to use the same system with your google voice account

+2
Nov 12 2018-10-12T00:
source share

To send SMS from a web application, you need to connect your application to the SMS gateway. Most SMS gateways provide an external API that you can use to do this. They usually have documentation that you can use to learn how to integrate SMS notification into your PHP code. Unfortunately, there is no reliable free sms service, so you need to pay for this sms service. You can check out http://www.phpjabbers.com/web-sms/ , which seems to work very easily. Their integration code is pretty simple:

 <?php $SMSLIB["phone"] = '44111222333'; // your phone number $SMSLIB["key"] = 'abcdefghijklmnopqrs'; // your personal API code include("smslib.php"); // we will provide you with smslib.php file sendSMS("test message", $SMSLIB["phone"]); // function which sends the message ?> 
+2
Aug 31 '11 at 10:23
source share

PHP needs to call RestAPIs external messaging service to send SMS. You can call in two ways:

API calls using Curl: you need to set curl on the server and use it as

  $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $sms_gateway_url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); 

Else Use PHP file_get_contents()

Here is a PHP class and test code for sending sms using Bulk sms gateway , which you can try using your web application.

+2
Sep 15 '16 at 9:54 on
source share

I recently had to implement a custom sms function on our website and found the useful service www.dotgo.com. It's free ... it looks like it was created by several PhDs as a kind of illiterate messaging engine (think of the http request-response model).

For its operation, you have configured the index.crml file (similar to index.html, php, etc.). Our view is as follows (sorry that all this is put on one line ... with some problems that it displays otherwise):

 <?xml version="1.0" encoding="UTF-8"?><cmrl xmlns:dotgo="http://dotgo.com/cmrl/1.0"><match pattern="*"><engine href="http://www.bulbstorm.com/sms/flashbulb.php"/></match></cmrl> 

On our site, the index file, in turn, refers to the file /sms/flashbulb.php, which (with the exception of opening and closing php tags) looks like this:

 $wordArray = explode(' ',$_REQUEST['sys_argument']); $username = strip_tags($wordArray[0]); $messageBody = str_replace($username.' ', '', $_REQUEST['sys_argument']); require_once 'Database.php'; $dbh = new Database('bulbstorm'); $args = array($username, $messageBody); $dbh->execMysqlProc('uspAddFlashbulb', $args); print "<message><content>Bulb received and saved to your account</content></message>"; 

In any case, I only include code to give some idea of ​​how the framework works and how little code to write to get something functional.

There are some limitations. The main thing is that everything is user initiated. Therefore, if you primarily want to send outgoing messages that are not preceded by your user sending a message to your site in order to “receive” a response message, this may not be what you want. However, we have been working on what we are doing. One of the founders even personally answered the question by e-mail and was very useful.

One of the functions that we have not yet used, but examined their subscription functionality ... where users can configure it so that the dotgo system periodically polls the page on your site by sending an SMS message to them according to the schedule specified by the user. Again, I did not take it that far, but I thought it was interesting.

+1
Jan 19 '09 at 20:09
source share

In principle, each airline has a mail gateway to which it is necessary to send an email. You will need to know the carrier in advance so that you know which email address should send an SMS message.

0
Jan 11 '09 at 13:48
source share

Several SMPP libraries are available for PHP, one of which is the following. This is the protocol used to communicate with the SMS server.

http://pear.php.net/reference/Net_SMPP-0.4.3/Net_SMPP/_SMPP_Net_SMPP-0.4.3_SMPP_php.html

0
Jan 11 '09 at 14:26
source share

I used the below SMS SMS API URL in PHP using jQuery ajax, and also you can store every sms information in mysql database for tracking.

demo SMS Gateway API using PHP and Ajax

0
Jan 30 '15 at 11:13
source share

Mobile messaging notifications contains the PHP API for sending SMS messages.

0
Feb 23 '15 at 22:34
source share
 function sendSMS($number,$message) { $request = message api link; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $response = curl_exec($ch); curl_close($ch); return split(',',$response); } 
0
Jul 06 '15 at 13:10
source share

We recommend using the multigateway solution. I created it for my purposes, but I think it can be useful for those who want to easily configure: https://packagist.org/packages/orajo/sms-zilla p>

 $smsSender = new SmsZilla\SmsSender(new SmsZilla\Adapter\MockAdapter()); $smsSender->setRecipient('605123456'); // adding more recipients (with and without country code) $smsSender->setRecipient(['511654321', '48511654987', '+41751654987']); $smsSender->setText("Message text"); $result = $smsSender->send(); 

Now this library supports 5 providers, the 6th in dev, and others are planned.

0
Aug 28 '17 at 14:57
source share

You can use our API and this tutorial that covers the topic.

But, in principle, sending one SMS message is as simple as sending an HTTP POST request:

 curl -X "POST" https://api.wavecell.com/sms/v1/amazing_hq/single \ -u amazing:1234512345 \ -H "Content-Type: application/json" \ -d $'{ "source": "AmazingDev", "destination": "+6512345678", "text": "Hello, World!" }' 

Where amazing is your account, 1234512345 is your password (use stronger passwords!) And amazing_hq is your subaccount.

The result is: SMS

Details about sending an HTTP request in PHP are discussed in the following questions:

  • POST request with JSON body
  • POST data for URL in PHP
  • How to send a POST request with PHP?
0
Sep 17 '17 at 18:30
source share

I think this is the oldest question on this topic. Mostly the answers are paid gateway ads. But there is another way - SMS from an Android device (SIM card), an Android gateway. I created a free open source application with a simple API: https://github.com/pavelakafoks/SmsTransmitter Google play: https://play.google.com/store/apps/details?id=info.ininfo.smstransmitter. You can use my application for your site or create your own Android application based on my sources. It is cheaper than Internet SMS gateways. I hope this is useful to someone.

0
Jun 10 '18 at 10:02
source share



All Articles