/    Sign up×
Community /Pin to ProfileBookmark

Send SMS text and retrieve data via PHP

SMS Gateways are awfully expensive and I would honestly like to send SMS to customers registered via our website. I have done that by using the php mail function as “[email protected]“. Now I would like to have people be able to reply via SMS and have a PHP script take the data in and send them another output based on their request.

Is their any possibly that a person could SMS text to a php script? Any help or direction would be great!

Thanks,
Big Ross

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@Phill_PaffordApr 13.2009 — Not possible sorry. To receive a SMS text message you need to have a Short Code, this is a number that the carriers (Like AT&T) use to send and receive SMS text messages. Although it is possible to send to mobile devices via the SMS Gateway email addresses you would need to use a short code to receive SMS messages to a script. There are organizations out there that provide this type of service, but there is no solution to do this for free. Maybe something more like the Twitter API would work for you? I know there are many scripts in PHP for this.
Copy linkTweet thisAlerts:
@bigross1324authorApr 13.2009 — Ok, that does make sense.

Although at one point in time, I read about someone who used a PHP script that grabbed emails from a mailbox and did it that way but I guess it will not work the way I would like.

Would you recommend the cheapest and best SMS Gateway to use?
Copy linkTweet thisAlerts:
@drhart4000Apr 14.2009 — Well, when you send a text message to a phone via its carrier email address. The recipient can reply to the message, it'll simply send an email to the specified reply to address. (I.E. If i send an email to [email][email protected][/email] with the reply address of [email][email protected][/email]. When the phone user replys to the message you will get an email at [email][email protected][/email] from [email][email protected][/email]. all phones and carriers work this way).

To make this work you would have to run the script as a process (I.E. in the background) if you have the ability to do this(or if its your server), some webhosts disallow this, contact your provider.

Now as far as keeping tabs on which emails belong to which convo, I would suggest, assigning an email for every user that sends an sms, such as [email][email protected][/email], or [email][email protected][/email]. You don't have to make the mailboxes for these account you can use a catch all mail account, this will receive all email that doesn't have a valid mailbox. With your php script you can then check for messages in that inbox, and work everything out accordingly(get username from the recipient address, add the message to the convo, send email update, etc). Note: doing it this way will allow your users to beable to hand out that address to all their buddies, and have anyone initiate the convo, if you desire. ?

Note, you will need to check this inbox every xx mins, or xx secs, which might have an impact on your server you will have to play around with this. You can also look at writing up an imap script wich will just wait for push notifications from your mail server if you have IMAP available. This would probably be the best option, and if you program your fronted in ajax, you can have that sms show up instantly. There will be less of an impact on your server as your not pooling the email server every xx secs, and you can send notifications the instant an email arrives.

POP3: http://www.weberdev.com/get_example-4015.html

IMAP: http://www.devarticles.com/c/a/PHP/Create-Your-Own-Mail-Script-With-PHP-and-IMAP/

If you have shell access with your provider or its your server, you can use the command line to run your script. But you can also use somthing like the following code in a php file on your web host, to start the process.
[code=php]<?php
exec ("/usr/bin/php yourscript.php >/dev/null &");
?>[/code]

http://www.php.net/function.exec

I was actually thinking about building something similar to this. It's on the back burner but those where my thoughts on the project. It'll take a little bit of work, but its completely plausible.

On a side note, I'm not sure how you currently go about finding what the carrier for a specific number is, most people ask for the carrier. There are services out there such ass http://www.serviceobjects.com/products/phone/geophone-wireless that provide reverse hookups, I think there are a couple free ones out there. I'm looking for one now. But that would also be something to consider if you don't offer this already. If you do use a reverse lookup service that charges per lookup i would recommend storing the numbers in a database, so you don't lookup the carrier each time... If you've come across from free api service for this I'd love to hear about it!

Regards,

Wayne Hartmann
Copy linkTweet thisAlerts:
@drhart4000Apr 14.2009 — I just Came accross the Zeep Mobile API, which looks very interesting, note that this service puts adds into your sms's. You may want to look into it aswell. It's more web services based compared to communicating with friends via sms.

.

http://zeepmobile.com/developers/
Copy linkTweet thisAlerts:
@Phill_PaffordApr 14.2009 — WOW Zeep Mobile looks to be a good thing. I have signed up for this to test things out.
×

Success!

Help @bigross1324 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.13,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,
)...