public function manage()
 {
     if (IS_POST) {
         if (isset($_POST['login'])) {
             // login
             $smsClient = new SmsClient();
             $stats = $smsClient->login();
             if ($stats !== null && $stats !== false && $stats == 0) {
                 $this->success('登录成功!', U('Sms/index'));
             } else {
                 echo '登录失败。错误码:' . $stats;
                 //$this->error('登录失败!'.$stats, U('Sms/index'));
             }
         } else {
             if ($_POST['logout']) {
                 // logout
                 $smsClient = new SmsClient();
                 $stats = $smsClient->logout();
                 if ($stats !== null && $stats !== false && $stats == 0) {
                     $this->success('注销成功!', U('Sms/index'));
                 } else {
                     echo '注销失败。错误码:' . $stats;
                     //$this->error('注销失败!'.$stats, U('Sms/index'));
                 }
             }
         }
     }
 }
 public function notify($token, $func, $text, $touser = null)
 {
     $user = M('wxuser')->where(array('token' => $token))->find();
     if (empty($user)) {
         return -1;
     }
     $uid = $user['uid'];
     // 检查提醒是否开启
     $smsset = M('sms_set')->where(array('token' => $token))->find();
     if (empty($touser) && strpos($smsset['function'], $func) === false) {
         return -1;
     }
     // 检查是否有余额
     $sms_account_db = M('smsaccount');
     $smsacount = $sms_account_db->where(array('user_id' => $uid))->find();
     if ($smsacount['total'] <= $smsacount['used']) {
         //余额不足
         $data['statusCode'] = '10000';
     }
     if (empty($touser)) {
         $touser = $smsset['tel'];
     }
     //检查号码格式
     if (!preg_match("/^1[3-9]{1}[0-9]{9}\$/", $touser)) {
         //接收短信号码格式不对
         $data['statusCode'] = '10001';
     }
     $data['charged_count'] = $this->countSms($text);
     if ($data['charged_count'] > $smsacount['total'] - $smsacount['used']) {
         //余额不足
         $data['statusCode'] = '10000';
     }
     if (!isset($data['statusCode'])) {
         // send
         $smsClient = new SmsClient();
         $data['statusCode'] = $smsClient->sendSMS(array($touser), $text, time());
         if ($data['statusCode'] === '0') {
             // statuscode可以为空
             //'0'是扣费成功
             $sms_account_db->where(array('user_id' => $uid))->save(array('used' => $smsacount['used'] + $data['charged_count']));
         }
     }
     $data['token'] = $token;
     $data['touser'] = $touser;
     $data['sendtime'] = time();
     $data['content'] = $text;
     $data['func'] = $func;
     // 记录
     M('sms_list')->add($data);
     if ($data['statusCode'] === '0') {
         return 0;
     }
     return -1;
 }
 public function actionIndex()
 {
     $return = array('error' => 0, 'msg' => '');
     if (Yii::app()->request->isPostRequest) {
         $phone = Formatter::formatPhone($_POST['phone']);
         if (Formatter::isVinaphoneNumber($phone)) {
             if (!isset($_COOKIE["verifyWifiEvent"])) {
                 if (isset($_SESSION['countverifyWifiEvent'])) {
                     unset($_SESSION['countverifyWifiEvent']);
                 }
                 $_SESSION['countverifyWifiEvent'] = 1;
                 $_SESSION['phoneverifyWifiEvent'] = $phone;
                 setcookie("verifyWifiEvent", 1, time() + 600);
             } else {
                 $_SESSION['countverifyWifiEvent']++;
                 if ($_SESSION['countverifyWifiEvent'] > 3) {
                     $return['error'] = 1;
                     $return['msg'] = "Quí khách đã vượt quá số lần xác thực. Vui lòng thử lại sau ít phút.";
                 }
             }
             if ($return['error'] == 0) {
                 try {
                     $userVerify = UserVerifyModel::model()->findByAttributes(array('msisdn' => $phone, 'action' => 'register_event83'));
                     if (!empty($userVerify)) {
                         $verifyCode = $userVerify->verify_code;
                     } else {
                         $verifyCode = rand(1000, 9999);
                         $verifyModel = new UserVerifyModel();
                         $verifyModel->setAttribute('created_time', date("Y-m-d H:i:s"));
                         $verifyModel->setAttribute('msisdn', $phone);
                         $verifyModel->setAttribute('verify_code', $verifyCode);
                         $verifyModel->setAttribute('action', 'register_event83');
                         $verifyModel->save();
                     }
                     $sms = new SmsClient();
                     $content = "Ma xac thuc dang ky tren chacha la: " . $verifyCode;
                     $sms->sentMT("9234", $phone, 0, $content, 0, "", time(), 9234);
                     $this->redirect('/event/register/verifyWifi');
                 } catch (Exception $exc) {
                     echo $exc->getTraceAsString();
                 }
             }
         } else {
             $return['error'] = 2;
             $return['msg'] = "Số điện thoại của bạn không phải là thuê bao Vinaphone!";
         }
     }
     $this->render('index', array('return' => $return));
 }
Exemple #4
0
 public static function getInstance()
 {
     if (null === self::$_instance) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
<?php

/**
 * Subscribe and unsubscribe to MO (mobile originated messages) events.
 *
 * Use ../examples.php to test this file
 */
require_once '../oneapi/client.php';
$smsClient = new SmsClient(USERNAME, PASSWORD);
$smsClient->login();
// Get all current subscriptions:
$moSubscriptions = $smsClient->retrieveInboundMessagesSubscriptions();
echo 'Success:', $moSubscriptions->isSuccess(), "\n";
echo 'Found ', sizeof($moSubscriptions->subscriptions), ' subscriptions', "\n";
if (!$moSubscriptions->isSuccess()) {
    echo 'Error getting the list of subscriptions';
    die;
}
// Remove them one by one:
foreach ($moSubscriptions->subscriptions as $subscription) {
    print $subscription;
    $deleteSubscriptionResult = $smsClient->cancelInboundMessagesSubscription($subscription->subscriptionId);
    echo $deleteSubscriptionResult->isSuccess(), "\n";
}
// Create new subscriptions:
$moSubscription = new MoSubscription();
$moSubscription->notifyURL = MO_NOTIFY_URL;
$moSubscription->callbackData = 'any string';
$moSubscription->criteria = 'test' . rand(10000000, 100000000);
$moSubscription->destinationAddress = MO_NUMBER;
$createSubscriptionsResult = $smsClient->subscribeToInboundMessagesNotifications($moSubscription);
Exemple #6
0
<?php

require 'classes/database.class.php';
require 'classes/LiqPay.php';
require 'classes/email.class.php';
require 'classes/smsclient.class.php';
$params = (require 'params.php');
$publicKey = $params['liqpay']['publicKey'];
$privateKey = $params['liqpay']['privateKey'];
$liqpay = new LiqPay($publicKey, $privateKey);
$db = new Database();
$email = new Email();
$allInActiveOrder = $db->getInactiveOrders();
$sms = new SmsClient($params['SmsUkraine']['login'], $params['SmsUkraine']['password']);
foreach ($allInActiveOrder as $order) {
    $res = $liqpay->api("payment/status", array('version' => '3', 'order_id' => $order['clientId']));
    if ($res->result == 'error') {
        if ($db->sendErrorSms($order['clientId'])) {
            if ($db->setAsError($order['clientId'])) {
                $sms->sendSMS('BurgerJoint', $order['phoneNumber'], 'Ваше замовлення скасовано. Для детальної iнформацiї звертайтесь за телефоном +38 (068) 235 50 29');
            }
        }
    } elseif ($res->result == 'ok') {
        if ($res->amount != $order['amount']) {
            $temp = ['res' => $res->amount, 'amount' => $order['amount'], 'check' => $res->amount != $order['amount']];
            $db->setAsError($res->order_id);
            $sms->sendSMS('BurgerJoint', $res->sender_phone, 'Ваше замовлення скасовано. Для детальної iнформацiї звертайтесь за телефоном +38 (068) 235 50 29');
            $htmlString = $email->postDataToString(array_merge((array) $res, ['-' => '-'], $order, $temp));
            $email->sendEmail('Данi не спiвпадають' . $htmlString, false, $order['clientId']);
        } else {
            if ($db->setAsPaid($order['clientId'])) {
<?php

require_once '../oneapi/client.php';
$smsClient = new SmsClient(USERNAME, PASSWORD);
$smsClient->login();
echo 'smsClient validity is ', $smsClient->isValid() ? 'true' : 'false', "\n";
$dataConnectionProfileClient = new DataConnectionProfileClient(USERNAME, 'wrongpassword');
$dataConnectionProfileClient->login();
echo 'dataConnectionProfileClient validity is ', $dataConnectionProfileClient->isValid() ? 'true' : 'false', "\n";
assert(true === $smsClient->isValid());
assert(false === $dataConnectionProfileClient->isValid());
<?php

require_once 'app.php';
$result = SmsClient::unserializeDeliveryStatus();
// Process the delivery status here...
// We'll just save this object:
$fileName = PUSH_LOG_DIRECTORY . '/delivery-status-' . strftime('%Y-%m-%d %H:%M') . '.txt';
$data = print_r($result, true);
file_put_contents($fileName, $data);
// Not needed, but just for testing:
echo 'OK';
Exemple #9
0
 $amount = $request->totalPrice->sum;
 try {
     $db = new Database();
     $db->beginTransaction();
     $response = $db->insertClient($request->textMessage, $request->phoneNumber, $amount, json_encode($request));
     if (!$response['state']) {
         die('Server error. Please contact to administrator.');
     }
     if ($request->paymentMethod == 'onlinePayment') {
         // online paid
         $publicKey = $params['liqpay']['publicKey'];
         $privateKey = $params['liqpay']['privateKey'];
         $lp = new LiqPay($publicKey, $privateKey);
         $url = $lp->cnb_form(array('version' => '3', 'amount' => $amount, 'currency' => 'UAH', 'description' => 'payment for order ' . $response['id'] . ' for burgerjoint.com.ua', 'server_url' => "http://{$_SERVER['HTTP_HOST']}/scripts/server.php", 'result_url' => "http://{$_SERVER['HTTP_HOST']}/scripts/result.php?id={$response['id']}", 'order_id' => $response['id']));
     } else {
         $sms = new SmsClient($params['SmsUkraine']['login'], $params['SmsUkraine']['password']);
         $email = new Email();
         if ($email->sendEmail($request, true, $response['id'])) {
             $db->setAsPaid($response['id']);
             $sms->sendSMS('BurgerJoint', $params['adminNumber'], 'Нове замовлення ' . $response['id']);
             $url = 'http://' . $_SERVER['HTTP_HOST'] . '/index.html#/success';
         } else {
             $url = 'http://' . $_SERVER['HTTP_HOST'] . '/index.html#/failure';
         }
     }
     $db->commit();
     echo $url;
     die;
 } catch (Exception $e) {
     $email->sendEmail('Сталася помилка - ' . $e->getMessage(), false, $response['id']);
     $db->rollback();
<?php

/**
 * Send message and check for delivery status until it is delivered.
 *
 * Use ../examples.php to test this file
 */
require_once '../oneapi/client.php';
# example:initialize-sms-client
$smsClient = new SmsClient(USERNAME, PASSWORD);
# ----------------------------------------------------------------------------------------------------
# example:login-sms-client
$smsClient->login();
# ----------------------------------------------------------------------------------------------------
# example:prepare-message-without-notify-url
$smsMessage = new SMSRequest();
$smsMessage->senderAddress = SENDER_ADDRESS;
$smsMessage->address = DESTINATION_ADDRESS;
$smsMessage->message = 'Hello world';
# ----------------------------------------------------------------------------------------------------
# example:send-message
$smsMessageSendResult = $smsClient->sendSMS($smsMessage);
# ----------------------------------------------------------------------------------------------------
//
# example:send-message-client-correlator
// The client correlator is a unique identifier of this api call:
$clientCorrelator = $smsMessageSendResult->clientCorrelator;
# ----------------------------------------------------------------------------------------------------
$deliveryStatus = null;
for ($i = 0; $i < 4; $i++) {
    # example:query-for-delivery-status
Exemple #11
0
<?php

require_once 'oneapi/client.php';
# example:initialize-sms-client
$smsClient = new SmsClient("mbwilo", "YWtzx5PH");
# ----------------------------------------------------------------------------------------------------
$conn = mysql_connect("localhost", "root", "kevdom");
mysql_select_db("cervical");
$query = mysql_query('select * from notification WHERE status="pending"');
while ($row = mysql_fetch_array($query)) {
    #   example:prepare-message-without-notify-url
    if (strtotime($row['next_visit']) - strtotime(date('Y-m-d')) <= 86400) {
        $smsMessage = new SMSRequest();
        $smsMessage->senderAddress = "CECAP-PROGRAM";
        $smsMessage->address = "+255" . substr($row['phone_number'], 1);
        $smsMessage->message = $row['message'];
        # ----------------------------------------------------------------------------------------------------
        # example:send-message
        $smsMessageSendResult = $smsClient->sendSMS($smsMessage) or die;
        if ($smsMessageSendResult) {
            $query = mysql_query('UPDATE notification SET status="sent" WHERE id="' . $row['id'] . '"');
        }
        # ----------------------------------------------------------------------------------------------------
    }
}
<?php

require_once '../oneapi/client.php';
$smsClient = new SmsClient(USERNAME, PASSWORD);
$smsClient->login();
// Keyword to be used for MO messages:
$criteria = 'test' . rand(10000000, 100000000);
// Create new subscriptions:
$moSubscription = new MoSubscription();
$moSubscription->notifyURL = MO_NOTIFY_URL;
$moSubscription->callbackData = 'any string';
$moSubscription->criteria = $criteria;
$moSubscription->destinationAddress = MO_NUMBER;
// This step usually will be needed only once per application:
$createSubscriptionsResult = $smsClient->subscribeToInboundMessagesNotifications($moSubscription);
echo 'create subscriptions result:', $createSubscriptionsResult, "\n";
// Now that the subscription is saved, the application will push messages starting with $criteria and sent to $moNumber to $notifyURL
// Let's try to send a message ourselves (usually this will be done by the end user from a real mobile phone):
$smsMessage = new SMSRequest();
$smsMessage->senderAddress = '38598123456';
$smsMessage->address = $moSubscription->destinationAddress;
$smsMessage->message = $criteria . ' Some message';
$smsMessageSendResult = $smsClient->sendSMS($smsMessage);
echo 'The message is created, and you should receive a http push on ' . $moSubscription->notifyURL;
<?php

#require_once 'yapd/dbg.php';
require_once 'app.php';
if (!getFormParam('from') || !getFormParam('to') || !getFormParam('message')) {
    redirectWithFormError('send-message-form.php', 'From, to and message are mandatory');
}
// Construct the sms message object:
$message = new SMSRequest();
$message->senderAddress = getFormParam('from');
$message->address = getFormParam('to');
$message->message = getFormParam('message');
$message->notifyURL = getFormParam('notifyURL');
// Initialize the client:
$smsClient = new SmsClient(USERNAME, PASSWORD);
try {
    $result = $smsClient->sendSMS($message);
    redirectWithFormSuccess('send-message-form.php', '<h1>Message sent</h1><a href="check-delivery-status-form.php?clientCorrelator=' . $result->clientCorrelator . '">check delivery status</a>');
    return;
} catch (Exception $e) {
    redirectWithFormError('send-message-form.php', 'Error sending message:' . $e->getMessage());
    return;
}
<?php

require_once '../oneapi/client.php';
date_default_timezone_set("UTC");
$fromTime = OneApiDateTime::createFromFormat('Y-m-dTH:i:s....O', '1970-01-01T00:00:00.000+0000');
$toTime = new DateTime();
$messageId = sizeof($argv) >= 4 ? $argv[3] : null;
$smsClient = new SmsClient(USERNAME, PASSWORD);
$messages = $smsClient->retrieveOutboundMessages($fromTime, $toTime, $messageId);
foreach ($messages->logs as $message) {
    echo "Message: \n";
    echo "\tSend Date Time: " . $message->sendDateTime . "\n";
    echo "\tMessage Id: " . $message->messageId . "\n";
    echo "\tSMS Count: " . $message->smsCount . "\n";
    echo "\tDestaination Address: " . $message->destinationAddress . "\n";
    echo "\tSender Address: " . $message->sender . "\n";
    echo "\tClient Metadata: " . $message->clientMetadata . "\n";
    echo "\tMessage Text: " . $message->messageText . "\n";
    echo "\tStatus: \n";
    echo "\t\tId: " . $message->status->id . "\n";
    echo "\t\tStatus: " . $message->status->status . "\n";
    echo "\t\tDescription: " . $message->status->description . "\n";
    echo "\t\tFailure Reason: " . $message->status->failureReason . "\n";
    echo "\tBulkId: " . $message->bulkId . "\n";
    echo "\tDelivery Report Time: " . $message->deliveryReportTime . "\n";
    echo "\tPorted: " . $message->ported . "\n";
    echo "\tPrice:\n";
    echo "\t\tPrice: " . $message->pricePerMessage->price . "\n";
    echo "\t\tCurrency: " . $message->pricePerMessage->currency . "\n";
    echo "\tDestination Network: \n";
    echo "\t\tId: " . $message->destinationNetwork->id . "\n";
<?php

/**
 * Send message and check for delivery status untill it is delivered.
 *
 * Use ../examples.php to test this file
 */
require_once '../oneapi/client.php';
$smsClient = new SmsClient(USERNAME, PASSWORD);
$smsClient->login();
# example:prepare-message-with-notify-url
$smsMessage = new SMSRequest();
$smsMessage->senderAddress = SENDER_ADDRESS;
$smsMessage->address = DESTINATION_ADDRESS;
$smsMessage->message = 'Hello world';
$smsMessage->notifyURL = NOTIFY_URL;
# ----------------------------------------------------------------------------------------------------
$smsMessageSendResult = $smsClient->sendSMS($smsMessage);
$clientCorrelator = $smsMessageSendResult->clientCorrelator;
echo NOTIFY_URL;
echo $clientCorrelator;
<?php

require_once '../oneapi/client.php';
$smsClient = new SmsClient(USERNAME, PASSWORD);
// Keyword to be used for MO messages:
$criteria = 'test' . rand(10000000, 100000000);
// Create new subscriptions:
$moSubscription = new MoSubscription();
// Do not set notifyURL property for this one!
// $moSubscription->notifyURL = ...;
$moSubscription->callbackData = 'any string';
$moSubscription->criteria = $criteria;
$moSubscription->destinationAddress = MO_NUMBER;
// This step usually will be needed only once per application:
$createSubscriptionsResult = $smsClient->subscribeToInboundMessagesNotifications($moSubscription);
// Now that the subscription is saved, the application will store messages starting with $criteria and sent to $moNumber for you
// Let's try to send a message ourselves (usually this will be done by the end user from a real mobile phone):
$smsMessage = new SMSRequest();
$smsMessage->senderAddress = '38598123456';
$smsMessage->address = $moSubscription->destinationAddress;
$smsMessage->message = $criteria . ' Some message';
$smsMessageSendResult = $smsClient->sendSMS($smsMessage);
// Sleep a few seconds just to be sure the message is processed:
echo 'Waiting for the message to be processed...';
sleep(20);
// Note: the time lag depends on a lot of things. Usually a few seconds will be OK, but it depends on the
// client roaming status, Newtorks, etc.
// OK, let's see if there are any SMS message waiting for us (of course there is one!):
$receivedInboundMessages = $smsClient->retrieveInboundMessages(100);
echo 'Found ', sizeof($receivedInboundMessages->inboundSMSMessage), ' messages', "\n";
foreach ($receivedInboundMessages->inboundSMSMessage as $inboundMessage) {
<?php

require_once 'app.php';
$smsClient = new SmsClient(USERNAME, PASSWORD);
$result = $smsClient->retrieveInboundMessages();
$result->inboundSMSMessage;
?>
<html>
    <head>
        <title>Inbound messages</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    </head>
    <body>
        <h1>Inbound messages</h1>
        <?php 
if ($result->inboundSMSMessage) {
    ?>
            <ul>
                <?php 
    foreach ($result->inboundSMSMessage as $message) {
        ?>
                   <li/> Message <b><?php 
        echo $message->message;
        ?>
</b> from <b><?php 
        echo $message->senderAddress;
        ?>
</b>.
                <?php 
    }
    ?>
<?php

#require_once 'yapd/dbg.php';
require_once 'app.php';
$clientCorrelator = getFormParam('clientCorrelator');
if (!$clientCorrelator) {
    redirectWithFormError('check-delivery-status-form.php', 'Client correlator is mandatory');
}
// Initialize the client:
$smsClient = new SmsClient(USERNAME, PASSWORD);
try {
    $result = $smsClient->queryDeliveryStatus($clientCorrelator);
    redirectWithFormSuccess('check-delivery-status-form.php', '<h1>Delivery status is ' . $result->deliveryInfo[0]->deliveryStatus . '</h1>');
    return;
} catch (Exception $e) {
    redirectWithFormError('check-delivery-status-form.php', 'Error sending message:' . $e->getMessage());
    return;
}
<?

require_once 'oneapi/client.php';

$json = '{"deliveryInfoNotification":{"deliveryInfo":{"address":"tel:38598123456","deliveryStatus":"DeliveredToTerminal"},"callbackData":"1234"}}';

$status = SmsClient::unserializeDeliveryStatus($json);

assert($status->callbackData == "1234");
<?php

require_once '../oneapi/client.php';
$smsClient = new SmsClient(USERNAME, PASSWORD);
$smsClient->login();
// Keyword to be used for MO messages:
$criteria = 'test' . rand(10000000, 100000000);
$request = new SubscribeToDeliveryNotificationsRequest();
$request->senderAddress = SENDER_ADDRESS;
$request->criteria = $criteria;
$request->notifyURL = NOTIFY_URL;
$request->criteria = 'test' . rand(10000000, 100000000);
$subscriptionResult = $smsClient->subscribeToDeliveryStatusNotifications($request);
if (!$subscriptionResult->isSuccess()) {
    echo 'Error subscribing';
    Logs::printLogs();
    die;
}
echo 'Subscribed to delivery reports sent to ', $request->senderAddress, ' reports for messages starting with ', $criteria, ' will be pushed to ', $request->notifyURL, "\n";
// List all currently active subscriptions:
$subscriptions = $smsClient->retrieveDeliveryNotificationsSubscriptions();
echo 'Found ', sizeof($subscriptions->deliveryReceiptSubscriptions), ' subscriptions', "\n";
foreach ($subscriptions->deliveryReceiptSubscriptions as $subscription) {
    // When needed, you can unsubscribe:
    $cancelResponse = $smsClient->cancelInboundMessagesSubscription($subscription->subscriptionId);
    if (!$cancelResponse->isSuccess()) {
        echo 'Error unsubscribing';
        Logs::printLogs();
        die;
    }
    echo 'Cancelled subscription to ', $subscription->subscriptionId, "\n";
<?php

require_once '../oneapi/client.php';
$smsClient = new SmsClient(USERNAME, PASSWORD);
$smsClient->login();
# example:retrieve-inbound-messages
$inboundMessages = $smsClient->retrieveInboundMessages();
foreach ($inboundMessages->inboundSMSMessage as $message) {
    echo $message->dateTime;
    echo $message->destinationAddress;
    echo $message->messageId;
    echo $message->message;
    echo $message->resourceURL;
    echo $message->senderAddress;
}
# ----------------------------------------------------------------------------------------------------
 public function actionShare()
 {
     $userPhone = yii::app()->user->getState('msisdn');
     $isShare = GameEventActivityModel::isShareOnDay($userPhone, date('Y-m-d'));
     if ($isShare) {
         $this->redirect('/event/play/thank');
         Yii::app()->end();
     }
     $error = 0;
     $isSend = false;
     if (Yii::app()->request->isPostRequest) {
         $isSend = 0;
         $phoneList = $_POST['phone_list'];
         if ($phoneList != '') {
             $phoneArr = explode(',', $phoneList);
             if ($phoneArr) {
                 foreach ($phoneArr as $key => $value) {
                     $phone = Formatter::formatPhone($value);
                     if (Formatter::isVinaphoneNumber($phone)) {
                         $isSend++;
                         $sms = new SmsClient();
                         $content = 'DV Chacha - Vinaphone kinh chao Quy Khach. Quy Khach vua duoc thue bao ' . $userPhone . ' moi dua tai trong chuong trinh "Vui cung Chacha - Nhan qua nhu y" voi giai thuong hap dan len toi 20 trieu dong. Chi tiet moi Quy Khach xem tai day http://m.chacha.vn/event';
                         $sms->sentMT("9234", $phone, 0, $content, 0, "", time(), 9234);
                     }
                 }
                 if ($isSend > 0) {
                     //chia se it nhat duoc 1 so vinaphone
                     $gameActivity = new GameEventActivityModel();
                     $gameActivity->setAttribute('user_phone', $userPhone);
                     $gameActivity->setAttribute('activity', 'share');
                     $gameActivity->setAttribute('point', 1);
                     $gameActivity->setAttribute('updated_time', date('Y-m-d H:i:s'));
                     $gameActivity->setAttribute('note', $phoneList, PDO::PARAM_STR);
                     $gameActivity->save();
                     $this->redirect('/event/play/thank');
                 }
             }
         } else {
             //ko có sô dt nao
             $error = 1;
         }
     }
     $this->render('share', array('isShare' => $isShare, 'error' => $error, 'isSend' => $isSend));
 }
 public function actionConfirmRegister()
 {
     $msisdn = Yii::app()->user->getState('msisdn');
     $package_id = 1;
     $code = rand(1000, 9999);
     $verify = new UserVerifyModel();
     $verify->user_id = 0;
     $verify->created_time = new CDbExpression("NOW()");
     $verify->msisdn = $msisdn;
     $verify->verify_code = $code;
     $verify->action = "register_package";
     $verify->params = json_encode(array('msisdn' => $msisdn, 'package' => $package_id));
     $ret = $verify->save();
     if ($ret) {
         $sendMsg = Yii::t('wap', Yii::app()->params['subscribe']['subscribe_otp'], array(':OTP' => $code));
         $smsClient = new SmsClient();
         $smsClient->sentSmsText($msisdn, $sendMsg);
         $result['error'] = 0;
         $promotion = UserSubscribeModel::model()->checkPromotion($msisdn);
         if ($promotion == 1) {
             if ($package_id == 2) {
                 $msg = 'Quý khách được MIỄN PHÍ 5 ngày nghe xem tải không giới hạn (sau KM, 7000đ/tuần). Mã xác thực đã được gửi về điện thoại của Quý khách. Xin vui lòng nhập mã OTP để đăng ký dịch vụ.';
             } else {
                 $msg = 'Quý khách được MIỄN PHÍ 5 ngày nghe xem tải không giới hạn (sau KM, 2000đ/ngày). Mã xác thực đã được gửi về điện thoại của Quý khách. Xin vui lòng nhập mã OTP để đăng ký dịch vụ.';
             }
         } else {
             if ($package_id == 2) {
                 $msg = 'Quý khách đang thực hiện đăng ký gói cước A7 trên dịch vụ Amusic. Mã xác thực đã được gửi về điện thoại của Quý khách. Xin vui lòng nhập mã OTP để đăng ký dịch vụ.';
             } else {
                 $msg = 'Quý khách đang thực hiện đăng ký gói cước A1 trên dịch vụ Amusic. Mã xác thực đã được gửi về điện thoại của Quý khách. Xin vui lòng nhập mã OTP để đăng ký dịch vụ.';
             }
         }
     } else {
         $msg = 'Có lỗi xảy ra, vui lòng thử lại sau!';
     }
     $this->render('confirm_register', compact('msg'));
 }
<?php

require_once '../oneapi/client.php';
define(FILE_NAME, '../message-' . mktime(true));
# example:on-mo
// returns a single message not array of messages
$inboundMessages = SmsClient::unserializeInboundMessages();
// Process $inboundMessages here, e.g. just save it to a file:
$f = fopen(FILE_NAME, 'w');
fwrite($f, "\n-------------------------------------\n");
fwrite($f, 'dateTime: ' . $inboundMessages->dateTime . "\n");
fwrite($f, 'destinationAddress: ' . $inboundMessages->destinationAddress . "\n");
fwrite($f, 'messageId: ' . $inboundMessages->messageId . "\n");
fwrite($f, 'message: ' . $inboundMessages->message . "\n");
fwrite($f, 'resourceURL: ' . $inboundMessages->resourceURL . "\n");
fwrite($f, 'senderAddress: ' . $inboundMessages->senderAddress . "\n");
# ----------------------------------------------------------------------------------------------------
echo 'OK';