Send and receive SMSs to a PHP script?
Asked Answered
S

4

11

Can a PHP script (which can be working with a MySQL DB) send and/or receive SMSs using some sort of server-side solution?

Any special server-side application, or special hardware required? And compatibility? Windows, Linux?

Sterol answered 3/1, 2009 at 22:42 Comment(1)
Can you provide your country? I know that SMS sending in Germany is a bit problematic, receiving even more.Eterne
D
7

There are plenty of companies like Esendex that offer APIs for sending/receiving SMS messages. I'm not sure if you're looking to send them directly from your hardware though?

Dunt answered 3/1, 2009 at 22:45 Comment(2)
Thanks, pretty much what I was looking for. Their 7 day no-credit-card trial sounds great too!Sterol
I've been using them for a few years, for both incoming and outgoing SMS, and they seem pretty ok. I've only used their .net APIs, but they seem to provide example code in a lot of languages.Dunt
U
1

You can get usb to gsm modems and send messages from php or any other language or you can develope J2EE programs on cellphones to do the same thing(this is hackier).

The cheapest way to do it(at less that was my experience) was to get a MultiTech GSM module for 50 USD, installed a GSM card with unlimited text and started comunicating using the serial port, very simple commands allows you to send text and the module makes all the protocol conections and stuff...

Basicly you end up using AT commands (they change from modem to modem) but they are like AT#T/"555031231" Sample Text message //

Of course the down side of going with the gsm chip is that you actually have to do some electronics, if you go for the high end gsm modems they have all the solved and you can just plug and play!

Underhand answered 3/1, 2009 at 23:53 Comment(0)
C
1

If you are in the UK, txtlocal is a good option. They already have example code on their site to get you up and running. Very simple, using curl functions.

http://www.txtlocal.co.uk/

Chamomile answered 4/1, 2009 at 7:52 Comment(0)
I
1

To send sms:

  1. CURL should be installed on your server. (Alternatively you can use php_file_get_contents function but i recommend CURL )
  2. SMS API from sms gateway server provider.

Here is a simple function to send sms using CURL:

function CURLsendsms($number, $message_body){
 $api_params = $api_element.'?apikey='.$apikey.'&sender='.$sender.'&to='.$mobileno.'&message='.$textmessage;
 $smsGatewayUrl = "http://springedge.com";
 $smsgatewaydata = $smsGatewayUrl.$api_params;
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_POST, false);
 curl_setopt($ch, CURLOPT_URL, smsgatewaydata);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 $output = curl_exec($ch);
 curl_close($ch);
 // Use file get contents when CURL is not installed on server.
 if(!$output){
 $output =  file_get_contents($smsgatewaydata);  
 }
}

Also you can use php class to send sms http://www.phpclasses.org/package/9522-PHP-Send-SMS-messages-with-Spring-Edge-API.html

There are two files in above class: sendsms.php - Class file to call sms gateway restAPI test.php - Example file to test sms function. This Class is using spring edge sms gateway provider API

To receive sms :

You need to purchase a virtual number which can be 10 digit virtual mobile number or short code number.

Virtual number can be configured with a HTTP URL with params as query string

Ex. example.com/receivesms.php?from=%number%&smstext=%text%

All the messages received on virtual number will be triggered to configured URL so you can process it further (Ex. Storing replies to DB or sending a text message in response) in your script as per requirement.

Virtual mobile number (2 way sms number) can be configured with any sms service provider

Inspirit answered 29/8, 2017 at 7:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.