public function testSmsReceiverObjSetters()
 {
     $rec = new SMSReceiver();
     $rec->setUpReceiver($this->sampleIdeamartSms());
     $this->assertEquals($rec->getVersion(), "1");
     $this->assertEquals($rec->getApplicationId(), "APP_0001");
     $this->assertEquals($rec->getAddress(), "tel:947123123");
     $this->assertEquals($rec->getMessage(), "Hello World Test");
     $this->assertEquals($rec->getRequestId(), "123123");
     $this->assertEquals($rec->getEncoding(), "text");
 }
Beispiel #2
0
<?php

require "../vendor/autoload.php";
// Application Details
$applicationId = "APP_0001";
$password = "******";
$smsIn = new SMSReceiver();
$address = $smsIn->getAddress();
$message = $smsIn->getMessage();
$url = "http://localhost:7000/sms/send";
$smsOut = new SMSSender($url, $applicationId, $password);
$smsOut->sms("Got the message", $address);
$smsOut->broadcast("This message is broadcasted - " . $message);
Beispiel #3
0
$PASSWORD = "******";
$EXTERNAL_TRX_ID = "123";
$production = false;
if ($production == false) {
    $CASS_SERVER_URL = "http://localhost:7000/caas/direct/debit";
    $SMS_SERVER_URL = "http://localhost:7000/sms/send";
} else {
    $CASS_SERVER_URL = 'https://api.dialog.lk/caas/direct/debit';
    $SMS_SERVER_URL = "https://api.dialog.lk/sms/send";
}
$logger = new Logger();
try {
    $receiver = new SMSReceiver();
    $message = $receiver->getMessage();
    // Get the message sent to the app
    $address = $receiver->getAddress();
    // Get the phone no from which the message was sent
    list($keyword, $amount) = explode(" ", $message);
    // Setting up CAAS
    $cass = new DirectDebitSender($CASS_SERVER_URL, $APP_ID, $PASSWORD);
    $sender = new SmsSender($SMS_SERVER_URL, $APP_ID, $PASSWORD);
    try {
        if (isset($amount)) {
            $cass->cass($EXTERNAL_TRX_ID, $address, $amount);
            $sender->sms("Thank you for your generosity, You Have made a donation for " . $amount . " Rupees", $address);
        }
    } catch (CassException $ex) {
        $logger->WriteLog($ex);
        $sender->sms("You do not have sufficient credit to make this donation", $address);
    }
} catch (Exception $e) {
// Licence : MIT License
// http://opensource.org/licenses/MIT
// ==========================================
ini_set('error_log', 'sms-app-error.log');
require_once 'lib/Log.php';
require_once 'lib/SMSReceiver.php';
require_once 'lib/SMSSender.php';
define('SERVER_URL', 'http://localhost:7000/sms/send');
define('APP_ID', 'APPID');
define('APP_PASSWORD', 'password');
$logger = new Logger();
try {
    // Creating a receiver and intialze it with the incomming data
    $receiver = new SMSReceiver(file_get_contents('php://input'));
    //Creating a sender
    $sender = new SMSSender(SERVER_URL, APP_ID, APP_PASSWORD);
    $message = $receiver->getMessage();
    // Get the message sent to the app
    $address = $receiver->getAddress();
    // Get the phone no from which the message was sent
    $logger->WriteLog($receiver->getAddress());
    if ($message == 'broadcast') {
        // Send a broadcast message to all the subcribed users
        $response = $sender->broadcast("This is a broadcast message to all the subcribers of the application");
    } else {
        // Send a SMS to a particular user
        $response = $sender->sms('This message is sent only to one user', $address);
    }
} catch (SMSServiceException $e) {
    $logger->WriteLog($e->getErrorCode() . ' ' . $e->getErrorMessage());
}