EsenAPE – send and receive SMS in real time using APE, jQuery, PHP and libape_controller
Here we have a sample demo of sending and receiving SMS (text messages) in real-time using APE’s libape_controller. We also utilize an SMS gateway called Esendex which is a UK based company – hence the name EsenAPE. When a message is sent to Esendex (e.g. you reply to the text you sent yourself) it will call a URL (RPC.php) we can then pass this onto APE for updating the users UI. The idea originated from a project I’ve just completed with work, Alert and Respond which basically does what this demo does but not in real time (polls every 30 seconds). It’s a good example of how to use the libape_controller – let me know what you think
Source Demo
This is just a proof of concept and shouldn’t be taken as a full application, it’s easy to use; enter your mobile number (with country code!), enter your message and click send. Once you’ve received the message on your phone you can reply to it and within seconds it’ll appear in your browser!
Please download the source and view my comments. Also, as SMS credits costs money I have only 20 remaining on the account so please only send one/two otherwise your IP address will be meeting my iptables. You can reply to the text as many times as you want.
Just a small note; I’ve tested this from the UK and SMS’ take less than one second to arrive to my phone and around 2 seconds until they appear on the screen of EsenAPE when I reply. innociv (from the USA) sent an SMS to his phone and took around 3 seconds. Please don’t forget to use your country code (001 for the USA).
Related posts:
- Using jQuery With APE – change the background-color with PHP
- Using jQuery with APE – an OOP approach with the DUI
- Using jQuery With APE
- Diving into APE modules and the JSF – creating topics for channels
- APE – An Introduction
14 Responses to “EsenAPE – send and receive SMS in real time using APE, jQuery, PHP and libape_controller”
Leave a Reply


Henning Horn on September 19th, 2009
Nice app, it works perfect here in Denmark, even our “special letters” work (Æ Ø Å).
It could be nice if one’s mobile-service-provider had something like this, especially the recieve function.
fish on December 20th, 2009
I’m thinking of implementing something similar to this for a community radio station in Kent. I’d like to have a look at how your code works, but unfortunately your links are broken!
Paul Price on December 20th, 2009
Hi Fish, my apologizes. I recently upgraded to APE v1.0 and totally forgot about the old demos, they should work fine now so test away
fish on December 20th, 2009
Cool, thanks for that! Works like a charm. Most impressive. I’ll pingback if we get something working based on this
Paul Price on December 21st, 2009
Yeah, it’s pretty damn fast as well. Just keep in mind this is pre-APE 1.0 so it’ll need some minor code changes but if you need a hand at all I’ll be glad to help
fish on December 21st, 2009
I’m going to have to make some significant changes to the PHP, since we use AQL.com to do our inbound SMS (it’s 10x cheaper to get an inbound number from AQL as opposed to Esendex).
We’re also looking at having a larger scope – so not just SMS but also RSS feeds, email, twitter updates and more, all going into the same inbox.
We are also going add to it by having historic messages get loaded up on startup. We’re logging all the messages in a DB, so we’ll have to figure out how to do that.
This will be the first thing I’ve done with APE, ha!
Paul Price on December 21st, 2009
I’m not sure about AQL’s API but with Esendex they provide a callback URL which makes the receiving of SMS’ lightning fast.
APE can definitely handle all of that without any problems
SSJS makes DB calls very easy and fast. The guys over at #ape-project on FreeNode are very helpful if you’re not too sure as their API doc isn’t complete yet!
fish on December 21st, 2009
AQL do the same – callback via HTTP POST*. It’s very quick – but our existing solution slows it right up. We generate a RSS feed from the logged messages, which gets updated on the client end when the RSS feeds are refreshed.
All this polling is pretty nasty – if we wanted it to be as fast as this we’d need to poll the feed once a second. Not very scalable at all. Thus why I’ve looked into AJAX Push/Comet servers.
I’m already on the #ape-project channel, I suspect I’ll have plenty of questions come tomorrow!
* Not to mention they’ve got IAX2 trunks so we can have people call the number and it’ll hit our PBX. Having one number to read out on air is a sure way to win the execs
Iwan on January 19th, 2010
Hy paul..
I’m Iwan from indonesian
I can’t test in your demo..
how can it work..
Ronald on February 2nd, 2010
is the sms working?
Paul Price on February 2nd, 2010
Hi Iwan/Ronald, the SMS test account ran out of credits but I’ve just topped it back up with another 25 so go a head and give it a try.
Regards, Paul.
Ronald Ward on February 3rd, 2010
How can I pass my user’s identity from PHP to APE? I would like to add something like this to my application, but I have to lock down the people to whom each user can send a message. I can’t just pass the userid in from PHP, because that can be easily spoofed. I am thinking something like sharing session info between PHP and APE. Can you point me in the right direction
Paul Price on February 3rd, 2010
Hi Ronald, I don’t have much experience with sessions, APE and PHP but maybe this is of use;
http://www.ape-project.org/wiki/index.php/Tutorial:Using_sessions
Ronald Ward on February 3rd, 2010
Thanks for responding so quickly. Maybe my question is simpler than this. I just need to be able to associate the authenticated user with his APE channel so that he doesn’t have to authenticate again.