public function testSmsReceiverMakeRequest()
 {
     $rec = new SMSReceiver();
     $json = $this->sampleIdeamartSms();
     $res = $rec->makeResponse($json);
     $this->assertEquals($res["statusDetail"], 'Process completed successfully.');
     $this->assertEquals($res["statusCode"], 'S1000');
     unset($json->sourceAddress);
     $res = $rec->makeResponse($json);
     $this->assertEquals($res["statusDetail"], 'Request is Invalid.');
     $this->assertEquals($res["statusCode"], 'E1312');
 }
示例#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);
示例#3
0
//Dialog Ideamart
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);
示例#4
0
// ==========================================
// Author : Pasindu De Silva
// 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) {
示例#5
0
    //Print error if any
    if (curl_errno($ch)) {
        echo 'error:' . curl_error($ch);
    }
    curl_close($ch);
    echo $output;
}
if (isset($_GET) && !empty($_GET) || isset($_POST) && !empty($_POST)) {
    if (isset($_REQUEST['keyword']) && !empty($_REQUEST['keyword'])) {
        if (isset($_REQUEST['number']) && !empty($_REQUEST['number'])) {
            if (isset($_REQUEST['message']) && !empty($_REQUEST['message'])) {
                $mobile = $_REQUEST['number'];
                $mess = $_REQUEST['message'];
                $keyword = $_REQUEST['keyword'];
                var_dump($_REQUEST);
                $message = $keyword . $mobile . $mess;
                SendMessage('9910065699', $message);
                $sms = new SMSReceiver();
                $sms->ProcessData($keyword, $mobile, $mess);
            } else {
                echo "ERROR : Message not sent -- Text parameter is missing!\r\n";
            }
        } else {
            echo "ERROR : Message not sent -- Phone parameter is missing!\r\n";
        }
    } else {
        echo "ERROR : Message not sent -- Keyword is missing!\r\n";
    }
} else {
    echo "ERROR : Message not received  -- Phone and Text parameter is missing!\r\n";
}