コード例 #1
0
ファイル: SmCaptchaAction.php プロジェクト: noikiy/wowewe
 public function run()
 {
     if (empty($_GET[SmCaptcha::MOBILE_ATTRIBUTE])) {
         throw new HttpException(404, '手机号不能空号!');
     }
     if (!U::mobileIsValid($_GET[SmCaptcha::MOBILE_ATTRIBUTE])) {
         throw new HttpException(404, '无效的手机号!');
     }
     $this->mobile = $_GET[SmCaptcha::MOBILE_ATTRIBUTE];
     $verifyCode = $this->getVerifyCode(true);
     return Json::encode(['code' => 0]);
     /*        
             if(isset($_GET[self::REFRESH_GET_VAR]))  // AJAX request for regenerating code
             {
                 $code = $this->getVerifyCode(true);
                 return Json::encode(array(
                     'hash1'=>$this->generateValidationHash($code),
                     'hash2'=>$this->generateValidationHash(strtolower($code)),
                     'url'=>$this->createUrl($this->controller->getId(),array('v' => uniqid())),
                 ));
             }
             else
             {         
                 throw new HttpException(404,'Just support ajax!');
             }
     */
 }
コード例 #2
0
ファイル: MStaff.php プロジェクト: noikiy/wowewe
 public function sendSm($content)
 {
     try {
         if (empty($this->mobile) || !U::mobileIsValid($this->mobile)) {
             U::W(["manager's mobile is empty or invalid", $this->getAttributes(), __METHOD__]);
             return false;
         }
         U::W("balance before is " . \app\models\sm\ESmsGuodu::B());
         //$s = Yii::$app->sm->S($this->mobile, $content, '', 'guodu', true);
         $s = Yii::$app->sm->S($this->mobile, $content, '', null, true);
         //U::W($s->resp);
         $err_code = $s->getErrorMsg();
         $className = get_class($s);
         $err_code .= get_class($s);
         $smQueue = new MSmQueue();
         $smQueue->gh_id = $this->gh_id;
         $smQueue->receiver_mobile = $this->mobile;
         $smQueue->msg = $content;
         $smQueue->err_code = $err_code;
         if ($s->isSendOk()) {
             U::W('Send Sm OK');
             $smQueue->status = MSmQueue::STATUS_SENT;
         } else {
             U::W(['Send Sm ERR', $err_code, $s->resp]);
             $smQueue->status = MSmQueue::STATUS_ERR;
         }
         $smQueue->save(false);
         U::W("balance after is " . \app\models\sm\ESmsGuodu::B());
     } catch (\Exception $e) {
         U::W($e->getCode() . ':' . $e->getMessage());
     }
     return true;
 }
コード例 #3
0
ファイル: CmdController.php プロジェクト: noikiy/wowewe
 public function actionSendsm()
 {
     $mobile = '15527766232';
     if (!U::mobileIsValid($mobile)) {
         echo "{$mobile} is a invalid mobile number!";
         return;
     }
     U::W("balance before is " . \app\models\sm\ESmsGuodu::B());
     //$s = Yii::$app->sm->S($mobile, 'hello world', '', 'guodu', true);
     //$s = Yii::$app->sm->S($mobile, 'hello world', '', null, true);
     $s = Yii::$app->sm->S($mobile, '【襄阳联通】, 您已订购商品', '', null, true);
     U::W($s->resp);
     $err_code = $s->getErrorMsg();
     $className = get_class($s);
     $err_code .= get_class($s);
     $smQueue = new MSmQueue();
     $smQueue->gh_id = '123';
     $smQueue->receiver_mobile = $mobile;
     $smQueue->msg = 'hello jack';
     $smQueue->err_code = $err_code;
     if ($s->isSendOk()) {
         U::W('Send OK');
         $smQueue->status = MSmQueue::STATUS_SENT;
     } else {
         U::W('Send ERR');
         $smQueue->status = MSmQueue::STATUS_ERR;
     }
     $smQueue->save(false);
     U::W("balance after is " . \app\models\sm\ESmsGuodu::B());
     echo 'Hello, world!!';
 }