diff --git a/composer.json b/composer.json index 30353d62..21ba450b 100755 --- a/composer.json +++ b/composer.json @@ -11,7 +11,10 @@ "symfony/http-foundation": "~3.4", "php-pushover/php-pushover": "dev-master", "paragonie/random_compat": "^2.0", - "twig/twig": "~2.0" + "twig/twig": "~2.0", + "plivo/plivo-php": "^4.0", + "callr/sdk-php": "^0.10" + }, "autoload": { "files": [ diff --git a/docs/intro.rst b/docs/intro.rst index e1d0aa9c..8132855f 100644 --- a/docs/intro.rst +++ b/docs/intro.rst @@ -61,6 +61,8 @@ The following SMS gateways are currently available: * FreeMobile (FR) - * Twilio - * CM Telecom - +* Plivo - +* Callr - Please note: for these gateways you will need an account with sufficient credits. diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index dde0f585..0fcc584c 100644 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -578,6 +578,12 @@ function psm_build_sms() { case 'twilio': $sms = new \psm\Txtmsg\Twilio(); break; + case 'plivo': + $sms = new \psm\Txtmsg\Plivo(); + break; + case 'callr': + $sms = new \psm\Txtmsg\Callr(); + break; } // copy login information from the config file diff --git a/src/psm/Module/Config/Controller/ConfigController.php b/src/psm/Module/Config/Controller/ConfigController.php index d0d80e2c..08f9c311 100644 --- a/src/psm/Module/Config/Controller/ConfigController.php +++ b/src/psm/Module/Config/Controller/ConfigController.php @@ -378,6 +378,8 @@ class ConfigController extends AbstractController { 'label_sms_gateway_freemobilesms' => psm_get_lang('config', 'sms_gateway_freemobilesms'), 'label_sms_gateway_clicksend' => psm_get_lang('config', 'sms_gateway_clicksend'), 'label_sms_gateway_twilio' => psm_get_lang('config', 'sms_gateway_twilio'), + 'label_sms_gateway_plivo' => psm_get_lang('config', 'sms_gateway_plivo'), + 'label_sms_gateway_callr' => psm_get_lang('config', 'sms_gateway_callr'), 'label_sms_gateway_username' => psm_get_lang('config', 'sms_gateway_username'), 'label_sms_gateway_password' => psm_get_lang('config', 'sms_gateway_password'), 'label_sms_from' => psm_get_lang('config', 'sms_from'), diff --git a/src/psm/Txtmsg/Callr.php b/src/psm/Txtmsg/Callr.php new file mode 100644 index 00000000..9c91a2d2 --- /dev/null +++ b/src/psm/Txtmsg/Callr.php @@ -0,0 +1,68 @@ +. + * + * @package phpservermon + * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 + * @version Release: @package_version@ + * @link http://www.phpservermonitor.org/ + **/ + +namespace psm\Txtmsg; + +class Callr extends Core { + // ========================================================================= + // [ Fields ] + // ========================================================================= + public $gateway = 1; + public $resultcode = null; + public $resultmessage = null; + public $success = false; + public $successcount = 0; + + // ========================================================================= + // [ Methods ] + // ========================================================================= + public function setGateway($gateway) { + $this->gateway = $gateway; + } + + public function sendSMS($message) { + //api stuff here + $api = new \CALLR\API\Client; + $api->setAuth(new CALLR\API\Authentication\LoginPasswordAuth($this->username, $this->password)); + + $options = new stdClass; + $options->force_encoding = 'GSM'; + $options->nature = 'ALERTING'; + $options->flash_message = false;//set to true if you don't want the SMS to be stored on the phone + + try { + foreach($this->recipients as $recipient) { + $api->call('sms.send', [$this->originator, $recipient, $message, $options]); + } + return 1; + } catch(Exception $e){ + if($e->getCode() == 22){ + return "Exception: Authentication failure\r\n"; + } else { + return $e->getMessage(); + } + } + } +} diff --git a/src/psm/Txtmsg/Plivo.php b/src/psm/Txtmsg/Plivo.php new file mode 100644 index 00000000..50889bf3 --- /dev/null +++ b/src/psm/Txtmsg/Plivo.php @@ -0,0 +1,63 @@ +. + * + * @package phpservermon + * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 + * @version Release: @package_version@ + * @link http://www.phpservermonitor.org/ + **/ + +namespace psm\Txtmsg; + +class Plivo extends Core { + // ========================================================================= + // [ Fields ] + // ========================================================================= + public $gateway = 1; + public $resultcode = null; + public $resultmessage = null; + public $success = false; + public $successcount = 0; + + // ========================================================================= + // [ Methods ] + // ========================================================================= + public function setGateway($gateway) { + $this->gateway = $gateway; + } + + public function sendSMS($message) { + $authId = $this->username; + $authToken = $this->password; + + $client = new \Plivo\RestClient($authId, $authToken); + /* @var $message_created \Plivo\Resources\Message\MessageCreateResponse */ + $message_created = $client->messages->create( + $this->originator, + $this->recipients, + $message + ); + + if($message_created && count($message_created->getMessageUuid()) ) { + return 1; + } else { + return $message_created->getMessage(); + } + } +} diff --git a/src/templates/default/module/config/config.tpl.html b/src/templates/default/module/config/config.tpl.html index d60eab4c..caf3a31e 100644 --- a/src/templates/default/module/config/config.tpl.html +++ b/src/templates/default/module/config/config.tpl.html @@ -203,6 +203,8 @@ + +