Exemplo n.º 1
0
 private static function pushNotification($SMSAddr, $message, $title = null, $url = null, $urltitle = null)
 {
     Notifications::addLog('UNTESTED !!! SMS[pushNotification' . ']; $SMSAddr=[' . $SMSAddr . ']; $message=[' . $message . ']; $title=[' . $title . ']; $url=[' . $url . ']; $urltitle=[' . $urltitle . ']', 'MESSAGING');
     /* Config params for SendSMS function of ExecEngine (using MessageBird.com)
      * Set the sender, could be a number (16 numbers) or letters (11 characters)
      * 
      */
     // Copy the following line to localSettings.php and provide settings
     // Config::set('sendSMSConfig', 'execEngine', array('username' => '', 'password' => '', 'sender' => ''));
     $config = Config::get('sendSMSConfig', 'msg_SMS');
     $username = $config['username'];
     $password = $config['password'];
     $sender = $config['sender'];
     Notifications::addLog('Username = '******'MESSAGING');
     // Set the Messagebird username and password, and create an instance of the MessageBird class
     $sms = new MessageBird($username, $password);
     // Set the sender, could be a number (16 numbers) or letters (11 characters)
     $sms->setSender($sender);
     // Add the destination mobile number.
     // This method can be called several times to add have more then one recipient for the same message
     $sms->addDestination($SMSAddr);
     //e.g. $sms->addDestination('31600000000');
     // Set an reference, optional
     // $sms->setReference('123456789');
     // Set a schedule date-time, optional
     // $sms->setTimestamp('2014-01-01 10:02');
     // Replace non GSM-7 characters by appropriate valid GSM-7 characters
     // $sms->setReplacechars(false);
     // If you want a dlr notification of the message send to another url then that you have set on the web site, you can use this parameter. Don't forget to set a reference!
     // $sms->setDlrUrl('http://www.example.com/dlr_url.php');
     // If $test is TRUE, then the message is not actually sent or scheduled, and there will be no credits deducted.
     Notifications::addLog("SMS testing is set to TRUE (messages are not actually sent)", 'MESSAGING');
     $sms->setTest(true);
     // Send the message to the destination(s)
     $sms->sendSms($message);
     if ($sms->getResponseCode() == "01") {
         Notifications::addSuccess('SMS message sent.');
     } else {
         Notifications::addError('SMS error: ' . $sms->getResponseMessage());
     }
     Notifications::addLog("SMS Response: " . $sms->getResponseMessage(), 'MESSAGING');
     Notifications::addLog("SMS Balance: " . $sms->getCreditBalance(), 'MESSAGING');
 }