api - Custom command line utility. How? -


Recently, I have released an open source class - one of the major API gateways available in the API function Provides an HTTP-API access to send SMS messages.

Now I want to create a custom command line utility, which can be available anywhere in the command line for the user, so he can send and send the SMS just like this console command:

< Pre> $ my_custom_send_sms_command -u your_username -p your_password -k your_api_key 447771234567 'hello CLI'

Please tell how this can be done?

Updated:

Class is written in PHP.

Make sure you have the PHP CLI package installed on my Ubuntu VPS:

  $ apt-get install php5-cli  

Check that it is installed:

  $ / usr / bin / php - V  

Then, create a file with something similar to sendsms.php :

  #! / Usr / bin / php -q & lt ;? Php // command line parameters are in the format: // key1 value1. KeyN valueN number message $ username = ""; $ Password = ""; $ Apikey = ""; ($ X = 0; $ x & lt; ($ argc - 3); $ x ++) {if ($ argv [$ x] == "-u") The process for the last two up to the user name Pair = $ Argv [$ x + 1]; If ($ argv [$ x] == "-p") $ password = $ argv [$ x + 1]; If ($ argv [$ x] == "-k") $ apikey = $ argv [$ x + 1]; } $ Number = $ argv [$ argc - 2]; $ Message = $ argv [$ argc - 1]; //: Call the SMS API // Now just the information for echo output ("user name =" .usernamename ". \ R \ n"); Echo ("password =". $ Password. "\ R \ n"); Echo ("API key =". Apikey. "\ R \ n"); Echo ("number =". $ Number. "\ R \ n"); Echo ("message =". $ Message. "\ R \ n"); ? & Gt;  

Make sure the files have executed permissions:

  chmod 755 sendsms.php  

and then run it Existing folder like this:

  $ ./sendsms.php -u your_username -p your_password -k your_api_key 447771234567 from 'Hello CLI'  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -