PHP controlled by SMS - php

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.

Related

Google Voice PHP API connect directly

Has anyone found a way to use google voice to send a phone call without first calling you. I need a phone to ring, but it is not necessary that any particular message be sent or anything. Here is the API I've been looking at. https://github.com/aaronpk/Google-Voice-PHP-API In the API you specify your google voice number and the recipient's number, and then it calls your phone and connects you to the recipient. I'm looking for a way to just connect to the recipient.
That's just the way Google Voice works... to call out you either a) use the web interface, which calls one of your phones then dials the other person or b) you call you own GV number and use the menu to dial out. The API packages I've looked at all use the GV mobile site to dial or send text messages (method a).
The only method I can think of for your scenario would be to get a free VoIP account with a number somewhere and set up a softphone that auto-answers.
But that begs the question... what is your purpose...? web driven prank calls?
I was using this for a system to alert people when a computer system I created needed attention. Text alerts are good...unless you're asleep and can't hear them. So, what I did was create a google voice number and then delete all of the phones off of it, and record a long voicemail. This way, it calls, and goes straight to a message that tells them the system needs attention and then they can just hang up and respond.
Slight work around, but it seems to work out fine.

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 add text by send the message to a number which when received will update the database accordingly.
You have some options - but a SMS gateway is the ideal solution.
Alternatively,
What you will do outside of a number - is to email from the phone. Using PHP - you can interpret the email to look for a keyword in the body or subject line and run a script accordingly.
All SMS capable phones can SEND email from text messages. Instead of entering number - you enter an email address.
It is a very lo-fi version of the implementation - but this method worked perfectly for me and for those not interested in investing in an SMS gateway.

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

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.

Processing input data from a phone though SMS

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.

Categories