phplocalhostcloudgammu

How to execute a shell_exec command from the cloud to my localhost


i am making a SMS sending website and im using Gammu as my local sms gateway, it is working fine in my localhost base on the php code i am using which is:

echo shell_exec('"C:\Gammu\bin\gammu.exe" --sendsms TEXT +'.$row["mobilenum"].' -text '.$message.'');

Now how i can execute this when i start putting the website on the cloud? I am using a window based for my SMS server.

Is there other way i can link the cloud and the localhost to just execute the gammu command?


Solution

  • Calling shell_exec() to gammu.exe on a cloud server won'r work as you don't have the phone connection.

    Instead of calling shell_exec() from your cloud hosted website, you will need to make a request via HTTP to a service which can do this.

    The easiest would be to use something like Twillio.com

    Or, you can also expose a simple HTTP API on your local network that is accesible for the cloud server to POST to.

    You would need a static IP on your local Gammu server, and the corresponding port opened in the firewall.

    So for example:

    POST http://100.22.33.11/sms?number=82736164617&text=Hello%20World

    or in JS

    $.post('http://100.22.33.11/sms',{
      number: '82736164617',
      text: 'Hello World'
    })
    

    Of course, you would also want to add some authentication (over SSL), to avoid being an open SMS proxy :)