Previously i want to talk about how to Utilize Runonreceive on Gammu for SMS Autoreply, this tutorial uses gammu 1.27.1990 version of Windows because a lot of tutorials – tutorials that are created when using gammu old version so it can not run when using a newer version of gammu. Gammu is very easy to use and supports many features that can be used, support for various kinds of mobile phones is also very good, not to mention the GPL license that made me fall in love with gammu:)
There are many options when we want to create applications that can autoreply SMS Gateway. Mas Stieven Kalengkian offer approach using task scheduler on windows, while mas Rosihan Ari offer approach by using the php file that runs in a browser. They can walk with the pros and cons – each. If we use the task scheduler on windows, then the checks can only be done for the time that has been set. If we add a batch file in the scheduler every minute it seems it is less effective because it is not real time and it also adds to the burden on the server side. On the other hand, if we use a browser that will run the php file to refresh a few seconds it’s also very burdensome than browser side, not to mention spent a lot of memory on the browser. Things – things like a separate issue instead?
I try to offer a better approach, namely by utilizing features on file smsdrc runonreceive exist in gammu. How does it work? Okay, I assume gammurc file is configured. Next we open the file smsdrc, then we will find the following lines:
1 2 |
# Script to be executed when new message has been received #runonreceive = /some/script |
We activate the option runonreceive we fill with a batch file
1 2 |
# Script to be executed when new message has been received runonreceive = D:/exec.bat #for example be filled like this |
Next we need to create a batch file that will execute the php file that will create autoreply. We can use the php CLI in the file exec.bat.
1 2 |
#The contents of the file exec.bat C:wampphpphp -f C:wampwwwproses.php |
Okay, batch file has finished running and smsdrc configuration is complete. Autoreply should have been able to walk, now we just need to make proses.php file that will send automatic replies when there is incoming sms.
1 2 3 4 5 6 7 8 |
<!--?php # Proses.php file used to send the reply when there is incoming sms # This is a POC file, can be adjusted as needed $sql = "SELECT ID, SenderNumber, TextDecoded FROM inbox WHERE processed = 'false'"; $qry = mysql_query($sql) or die(mysql_error()); while ($arr = mysql_fetch_array($qry)) { mysql_query("INSERT INTO outbox(DestinationNumber, TextDecoded) VALUES ('".$arr['SenderNumber']."', 'Hello, this is a reply your sms.')") or die(mysql_error()); mysql_query("UPDATE inbox SET processed='true' WHERE ID='".$arr['ID']."'"); } ?--> |
When everything is ready, we just run it by default Gammu service via the following command:
1 |
gammu-smsd -c smsdrc |
Then we try to send an SMS, what happens next? If you find that your SMS reply means you have successfully implemented runonreceive on Gammu. If not? please try again tutorial above how to Utilize Runonreceive on Gammu for SMS Autoreply
Hopefully helpful
source: imedia.web.id