当前位置: 首页>>代码示例>>PHP>>正文


PHP SMS::create方法代码示例

本文整理汇总了PHP中SMS::create方法的典型用法代码示例。如果您正苦于以下问题:PHP SMS::create方法的具体用法?PHP SMS::create怎么用?PHP SMS::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SMS的用法示例。


在下文中一共展示了SMS::create方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: countSMS

function countSMS($message, $mobile)
{
    $finalMessage = $message;
    $msg_count = 0;
    if (strlen($finalMessage) > 0 && strlen($finalMessage) <= 161) {
        $msg_count = 1;
    } elseif (strlen($finalMessage) > 161 && strlen($finalMessage) <= 307) {
        $msg_count = 2;
    } elseif (strlen($finalMessage) > 307) {
        $msg_count = 3;
    } else {
        echo 'msg not sent';
    }
    $mobileNoCount = count(explode(",", $mobile));
    $field_array = array('created' => date("Y-m-d H:i:s", time()), 'mobile' => $mobile, 'message' => $message, 'count' => $msg_count * $mobileNoCount);
    $medical_sms = new SMS();
    $medical_sms->create($field_array);
    //    $smsCount->create();
}
开发者ID:Akshayf444,项目名称:respi2,代码行数:19,代码来源:functions.php

示例2: auth

 /**
  * @return \Illuminate\Http\JsonResponse
  */
 public function auth()
 {
     //TODO rate limit
     //TODO Validation
     $udid = Input::get('udid');
     $phone = Input::get('phone');
     if (strlen($phone) < 9) {
         return $this->respondInsufficientPrivileges('Номер телефона слишком короткий');
     }
     if (intval($phone[2]) == 0) {
         return $this->respondInsufficientPrivileges('Вы пытаетесь зарегистрировать несуществующий номер.');
     }
     $providerCode = intval($phone[0] . $phone[1]);
     if (!in_array($providerCode, [99, 50, 51, 55, 70, 77])) {
         return $this->respondInsufficientPrivileges('Таких операторов не существует.');
     }
     $type = Input::has('type') ? Input::get('type') : 'verify';
     $phoneModel = Phone::withTrashed()->where('number', $phone)->first();
     if ($phoneModel && $type != 'reset') {
         if (!$phoneModel->deleted_at) {
             return $this->respondInsufficientPrivileges("Номер занят");
         }
         if (Carbon::now()->lte(Carbon::parse($phoneModel->deleted_at)->addDays(30))) {
             $allowedTime = Carbon::parse($phoneModel->deleted_at)->addDays(30);
             return $this->respondInsufficientPrivileges("Данный номер телефона не доступен для регистрации до {$allowedTime}");
         }
     }
     if ($type == 'changePhone') {
         if ($phoneModel) {
             return $this->respondInsufficientPrivileges("Number is already occupied");
         }
         $header = Request::header('Authorization');
         if (is_null($header)) {
             return $this->respondInvalidApi('Unauthorized');
         }
         if (!isset(explode(' ', $header)[1])) {
             return $this->respondInvalidApi('Unauthorized');
         }
         $token = explode(' ', $header)[1];
         if ($token) {
             $device = Device::where('auth_token', $token)->orderBy('id', 'desc')->first();
             $user = $device->user;
             if (!$user->checkPasswordAttribute(Input::get('password'))) {
                 return $this->respondInsufficientPrivileges('Wrong password');
             }
         }
     }
     if (!$phoneModel && $type == 'reset') {
         return $this->respondInsufficientPrivileges('Number not found');
     }
     $tempSMS = SMS::where('device', $udid)->where('phone', $phone)->orderBy('id')->first();
     if ($tempSMS) {
         $minTime = Carbon::parse($tempSMS->sent_at)->addMinutes(3);
         $maxTime = Carbon::parse($tempSMS->sent_at)->addHour();
         if ($tempSMS->verified) {
             if (Carbon::now()->lte($maxTime)) {
                 return $this->respond(['status' => 3, 'token' => $tempSMS->token]);
             }
         }
         if (Carbon::now()->lte($minTime)) {
             return $this->respond(['message' => 'Please wait ' . Carbon::now()->diffInSeconds($minTime) . ' seconds', 'timeout' => Carbon::now()->diffInSeconds($minTime), 'token' => $tempSMS->token, 'status' => 2]);
         }
         $tempSMS->code = rand(1000, 10000);
         $tempSMS->sent_at = Carbon::now()->toDateTimeString();
         // TODO Send sms
         $smsSender = new smsSender(fetchNumber($phone), $tempSMS->code);
         $smsSender->send(function ($res) {
             //				dd($res->xml());
         });
         $tempSMS->save();
         return $this->respond(['timeout' => 180, 'token' => $tempSMS->token, 'status' => 2]);
     } else {
         $code = rand(1000, 10000);
         $newSMSEntry = SMS::create(['phone' => $phone, 'code' => $code, 'token' => base64_encode(openssl_random_pseudo_bytes(32)), 'device' => $udid, 'sent_at' => Carbon::now()->toDateTimeString()]);
     }
     //TODO Send an SMS
     $smsSender = new smsSender(fetchNumber($phone), $code);
     $smsSender->send(function ($res) {
         //			dd($res->xml());
     });
     //SMS Logic
     if (isset($newSMSEntry)) {
         return $this->respond(['timeout' => 180, 'token' => $newSMSEntry->token, 'status' => 2]);
     }
     return $this->respondServerError('Something went wrong');
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:89,代码来源:AuthController.php


注:本文中的SMS::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。