Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/php -q
- <?php
- /**
- * cli2sms.php by Anton Raharja (antonrd@gmail.com)
- *
- * Example script to get data from shell script and send it as SMS via playSMS
- * You need to have a configured and working playSMS
- * In this example playSMS is accessible from http://localhost/playsms
- * Don't forget to chmod +x cli2sms.php to use it from Linux shell
- *
- * You may modify this script to suit your needs
- *
- * Example usage:
- * - get stat data (eg: uptime) and send it periodically (using cron) to admin's mobile phones
- * - https://aacable.wordpress.com/2015/07/30/playsms-send-sms-via-scriptcli-using-webservices-token/
- */
- // suppress error message
- error_reporting(0);
- // playSMS username/account for sending SMS
- $username = 'admin';
- // Webservices token for above username
- $token = '1194df9e20d06c3790f0c6fef49f174a';
- // playSMS Webservices URL
- $playsms_ws = 'http://localhost/playsms/index.php?app=ws';
- // destination numbers, comma seperated or use #groupcode for sending to group
- // $destinations = '#devteam,+6200123123123,+6200456456456';
- $destinations = '+6200123123123,+6200456456456';
- // get message to send from another shell script or Linux command, for example 'uptime'
- // $message = trim(shell_exec('/path/to/your/stat/shell/script/dot/sh'));
- $message = trim(shell_exec('uptime'));
- // send via playSMS HTTP API
- if ($message) {
- $ws = $playsms_ws . '&u=' . $username . '&h=' . $token . '&op=pv';
- $ws .= '&to=' . urlencode($destinations) . '&msg='.urlencode($message) . '&nofooter=1';
- $ret = @file_get_contents($ws);
- // echo $ret;
- echo "OK: message sent" . PHP_EOL;
- } else {
- echo "ERROR: message is empty" . PHP_EOL;
- }
- // end of script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement