EsenAPE – send and receive SMS in real time using APE, jQuery, PHP and libape_controller

September 18, 2009

EsenAPEHere 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).

Tags: , , , , , , , ,

36 Comments

  1. Henning Horn says:

    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.

  2. Henning Horn says:

    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.

  3. fish says:

    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!

  4. fish says:

    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!

  5. Paul Price says:

    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 :-)

  6. Paul Price says:

    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 :-)

  7. fish says:

    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 says:

      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 says:

        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 ;)

  8. fish says:

    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 says:

      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 says:

        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 ;)

  9. Iwan says:

    Hy paul..I’m Iwan from indonesianI can’t test in your demo..how can it work..

  10. Iwan says:

    Hy paul..I’m Iwan from indonesianI can’t test in your demo..how can it work..

  11. Ronald says:

    is the sms working?

  12. Ronald says:

    is the sms working?

  13. Paul Price says:

    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.

  14. Paul Price says:

    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.

  15. Ronald Ward says:

    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

  16. Ronald Ward says:

    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

  17. migarcia says:

    Hi Paul:A good job, with your permission I will leave a link to your sources LasFiguritas.com, but will use to explain what is APE.Sorry for the text-translation of Google :-)

  18. migarcia says:

    Hi Paul:A good job, with your permission I will leave a link to your sources LasFiguritas.com, but will use to explain what is APE.Sorry for the text-translation of Google :-)

  19. jl says:

    Hello Paul,have you tested any of your APE examples in chromium?Open up the inspector in the “network” tab and you’ll see that there’s an infinite “wait” for 0.ape.ifc0nfig.com which makes it look as though the page never fully loads. Firefox doesn’t have that problem. Any ideas on how to HIDE this “feature” ?

  20. jl says:

    Hello Paul,have you tested any of your APE examples in chromium?Open up the inspector in the “network” tab and you’ll see that there’s an infinite “wait” for 0.ape.ifc0nfig.com which makes it look as though the page never fully loads. Firefox doesn’t have that problem. Any ideas on how to HIDE this “feature” ?

  21. Sam says:

    Hi,How to configure server side filese.g for http://www.ape-project.org/demos/5/live-tweets.html

  22. Sam says:

    Hi,How to configure server side filese.g for http://www.ape-project.org/demos/5/live-tweets.html

  23. Otobong Okoko says:

    Hi,Can I use your source code and insert my sms settings. I tried testing the Demo but nothing has happened. Please if you still support the application, respond.Thank you.

  24. Otobong Okoko says:

    Hi,Can I use your source code and insert my sms settings. I tried testing the Demo but nothing has happened. Please if you still support the application, respond.Thank you.

Leave a Comment