Processing input data from a phone though SMS - php

I currently have a php script that reads email messages sent from phones and then it posts them on the internet...
I want to do the same thing but instead of reading emails, I would like to process the data through a SMS.
so, if someone sends a sms to X number, my program would get the message through this X number and use it in the site.
What would I need?

You have a lot of options here. Generally speaking you need to first acquire the number that people can SMS to. Afterwards a callback will be issued to you when someone sends and SMS and your PHP script can process the message and figure out what to do with it.
You essentially have a few options for exposing the SMS
Go with a dedicated short-code. Eg someone sends a text to 53234 and you will get a callback to deal with it. This is an expensive option. It will cost you generally around $2500/mo minimum not including per messaging fees. You can requisition a short code through a provider such as Open Market. You have to get approval for the short code which might take as much as 6 weeks.
Go with a shared short code. This is a bit cheaper -- you pay per message and it usually costs anywhere from .02 - .10 /msg depending on your msg volume. You get a keyword such as DOLLY that people have to preface before texting. So they would text DOLLY INPUT TEXT HERE to 53234 now and you would receive the callback with INPUT TEXT HERE. Celltrust and others provide shared short codes.
Use a public api that allows people to text in through something such as TextMarks. Textmarks is like a shared short code requires keyword usage + users to subscribe. However it is free which is great and has a nice callback API. I believe a service called Mozes also provides similar service. Finally, if you want you can set up a Twitter account and have people text to their number. Facebook also a similar API that allows you to use their FBOOK shortcode.

Ish's answer was great. I'd like to point out an additional free option.
Most carriers allow you to send SMS messages to email addresses. The SMS text gets inserted into the body of the email and the subject is carrier dependent. Once the email is sitting in your inbox, you can access it by the method of your choice.
This method has worked for me in a personal project requiring remote communication with my computer when all I had was a cell phone without internet capabilities.
This Wikipedia page shows how many carries support this (practically all).
Just try not to violate anyone's terms of service, you could always host the email account yourself.

Related

PHP controlled by SMS

I am looking to create a script that is run based on receiving and the content of a text. So I text a phone number (Google Voice number). And the script reads it and executes based on the content. Is the possible to do?
We use an SMS provider called textmagic, but many will be the same, in that they offer an API to use, and/or email notifications. You can set up your account to email you or call an web page with customer parameters when a text message is received (and indeed the other way round to text back).
One thing we used to do was hook up a mobile to a com-port and use our own sim, but this is very hacky and ought to be used as a last resort.

Force SMS messages sent from static email address to use the same number (AT&T example)

This specific example is using AT&T as the carrier of the receiver.
When sending SMS messages to clients via their carrier email address (1234567890#txt.att.net) from a static email address, the messages arrive on the phone from a number in the format of 1 (400) 000-244. Every time a new SMS message is sent, that number changes slightly. This causes phones, such as the iPhone, from properly threading the SMS messages that are coming from the same source email address.
Basic research shows that this has something to do with how AT&T's gateway handles turning emails into SMS messages. We've also looked at and decided that Common Short Codes (CSC) are not worth $1000 per month to purchase, so this is not an option for us.
Does anyone know of another way around this limitation in which it would be possible to force all SMS messages from the same source email to appear that way on the phone so that they are threaded correctly?
In our configuration, the emails are going out via SMTP using the PHP PEAR Mail_Mime package. We're really looking for a way we can do it on our end without the purchase of a shared or dedicated CSC.
Use:
<10 digit phone number>#mms.att.net
Instead of 'txt.att.net'
This will solve the short code dilemma.
For your AT&T issue they use a cluster model to send out SMS using the email gateway. To over come your problem there might be a couple of solutions but it all depends on what your needs are looks like they increment the phone number by one for each new message. Not sure how you could thread these.
Zeep Mobile lets you send SMS with a shared Short Code but they tag the end of your SMS message with ads, but the service is free (limited text per month I think)
Twilio might be a good cheap alternative as they offer such services. No short code but I believe they use the same From number for your threading issue.
Using your own GSM Modem could be an option but there is some work on getting this to work properly. Also it uses a Long Code (Think telephone number) instead of a Short Code.
There are a couple of other solutions so I will update my answer soon.
UPDATE:
Tropo
Google Voice

Web form autorespond with SMS

I have been asked to design a website for a client but one of the requirements is that there is a form which includes such things as name, email, dob and mobile number once the user submits the form a SMS is automatically sent to the users mobile almost like a autoresponder.
How to achieve this?
This can be done using an external SMS gateway which will not be free, but also not awfully expensive.
However, you say you are not a programmer. For this to be built well and most important of all, safely, it might be a good idea to use the services of one.
If you want to do it yourself, consider using a pre-paid plan with the SMS provider of your choice so you can't be ruined by a bot flooding your form with thousands of requests.
Web sms functionality can be added to any web application or website. As #Pekka said you need to use an external SMS gateway and to connect your application to this SMS Gateway. Most SMS gateways provide external API which can be used to do that. They usually have documentation which you can use to find out how to integrate SMS notification in your PHP code. Unfortunately there are no reliable free sms service provides so you have to pay for this sms service. You can check http://www.phpjabbers.com/web-sms/ which seems to work a lot easy. 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
?>
The easiest way to do this is to send it to their mobile numbers assigned email address (which is different by each carrier) then have it sent like a normal email.
The only issue is you will probably have to have a Dropbox with each carrier then add something to the PHP that changes the email address (ex. $tmobile would be tmomail.net).
More info:
How To Send Email To Any Cell Phone (for Free)
Most of mobile carriers offer free Email To SMS gateways which can be used to forward simple text emails to a mobile phones. And the good news, majority of those gateways are free and available to the general public.

How to update a mysql database via SMS text messaging?

I want to add an additional functionality to a CMS I am making that will allow users to add content to a site via text message. The user should be able to upload an image and add text and send the message to a number which when received will update the database accordingly.
Can this be done, and can it be done via PHP because that's the only language I know? Also what would be the general outline to achieve such a thing?
You have to find a SMS gateway that supports "incoming" of SMS. Click-a-tell is generally the one people choose because of their API and documentation, they aren't free though. If you do a quick Google search for "SMS Gateway" you'll find plenty of other solutions.
Once you choose the gateway you want to go with, the rest of the process is easy. You would just handle the SMS as a regular request into your application.
Hope that helps you get started!
Use one of the many SMS gateways out there like Twilio (whom I work for, but loved before I was an employee) which has a really simple API and great documentation. There are tons of PHP examples. When you receive a message, a simple POST request is made to a URL you specify with parameters for To, From and Body. Also if you return text from the URLs you use to receive messages you can respond back to them. You can also initiate outbound SMS from the same number using the REST API.
Twilio does not currently support MMS (needed for your image uploading requirement) and is not free, but you only pay for what you use at $.01 per message.
Completing the answer by Raphael Caixeta, I recommend that you use the standalone PHP binary to run a pre-determined script, which parameters you'll get from the SMS/MMS. This way you can separate the two process:
1) Make a script and test it by running it through the command line.
2) Implement the SMS/MMS receiver software so that it parses the messages and runs the first script with custom parameters.
You can use a GSM/3G modem (or dongle) to receive SMS messages. And this sms software can read those messages from the modem in real time and put them automatically in your database.

Web Application that receives images, videos, and text via Text Message

I've seen many examples of this (clickatell.com among them) that only support text in the USA. I need my application to receive images/videos from text messages (MMS?) from users. The web app needs to receive a way to identify the user (phone number) and the actual files (in the same fashion facebook has implemented for sharing photos via phone). Any ideas on how I can accomplish this? Would it be better to just create an app for iPhone and Android instead?
Location: United States (East Coast)
There may (or likely is) some MMS gateway that will allow your app to appear as another phone number (or short code), but I'm pretty sure you can just have people send the MMS message to an e-mail address. I believe that's standard (as in all carriers support it).
You'll just have to parse the sender's e-mail to find the phone number, and grab the attachment to find the file. You may need to 'detect' the correct attachment as some carriers add branding elements to the email.
Updated: From Wikipedia, it seems MMS to email gateways are 'common', but I guess not required.
E-mail and web-based gateways to the MMS (and SMS) system are common. On the reception side, the content servers can typically receive service requests both from WAP and normal HTTP browsers, so delivery via the web is simple. For sending from external sources to handsets, most carriers allow MIME encoded message to be sent to the receiver's phone number with a special domain.
So if your app needs to be completely accessible to everyone, this solution may not work. It is worth mentioning that popular file sharing site drop.io just uses an e-mail address for its MMS send/receive.
It's perfectly possible if you setup your own WAP gateway - usually this requires integration with the service providers - and they'll probably only be interested in talking to you if you'll be processing large volumes of messages (>10000 per day). If this does describe you, then you might want to have a look at Kannel.
For very small volumes, then you could achieve this with just a mobile phone and, again, Kannel. See the Kannel docs for supported devices.
If your volumes are somewhere in between, then you should probably be talking to a service aggregator (like clickatell) - sorry but I don't know whom provides such a service in the US.
HTH
C.

Categories