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
require 'alllibs.php';
$APP_ID = "APP_000001";
$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);