123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?php
- /**
- * 摘要:短信发送
- * user:liuyb
- */
- namespace App\Http\Controllers\Code\V2;
- use App\Http\Controllers\Controller;
- use App\Model\Code\V2\TrSms;
- use Illuminate\Http\Request;
- use Illuminate\Support\Facades\Validator;
- class SmsController extends Controller
- {
- //发送验证码
- public function singleSms(Request $request)
- {
- //验参
- $validator = Validator::make($request->all(), [
- 'account' => 'required|numeric',
- 'sign' => 'required|numeric',
- 'mobile' => 'required|size:11',
- 'content' => 'required',
- 'templateId' => 'required',
- ], [
- 'account.required' => '短息渠道账号不能为空',
- 'sign.required' => '签名id不能为空',
- 'mobile.required' => 'mobile不能为空',
- 'mobile.size' => 'mobile长度必须是11位',
- 'content.required' => 'content不能为空',
- 'templateId.required' => 'templateId不能为空',
- ]);
- if ($validator->fails()) {
- return $validator->errors()->all();
- }
- $account = $request->input('account'); //短信平台账号 153132952
- $sign = $request->input('sign'); //签名id 17522
- $mobile = $request->input('mobile'); //接受者手机号
- $content = $request->input('content'); //短信内容, 验证码
- $templateId = $request->input('templateId'); //模板id 29070
- $TrSmsModel = new TrSms();
- $result = $TrSmsModel->singleSend($account, $sign, $mobile, $content, $templateId);
- return $result;
- }
- //短信群发
- public function multiSms(Request $request)
- {
- //验参
- $validator = Validator::make($request->all(), [
- 'account' => 'required|numeric',
- 'sign' => 'required|numeric',
- 'mobile' => 'required',
- 'content' => 'required',
- ], [
- 'account.required' => '短息渠道账号不能为空',
- 'sign.required' => '签名id不能为空',
- 'mobile.required' => 'mobile不能为空',
- 'content.required' => 'content不能为空',
- ]);
- if ($validator->fails()) {
- return $validator->errors()->all();
- }
- $account = $request->input('account');//153132952
- $sign = $request->input('sign'); //17522
- $mobile = $request->input('mobile');//13522199350
- $content = $request->input('content');
- $templateId = $request->input('templateId'); //29070
- $scheduleSendTime = $request->input('scheduleSendTime');
- $TrSmsModel = new TrSms();
- $result = $TrSmsModel->multiSend($account, $sign, $mobile, $content, $templateId, $scheduleSendTime);
- return $result;
- }
- //短信模板
- public function templateList(Request $request)
- {
- //验参
- $validator = Validator::make($request->all(), [
- 'account' => 'required|numeric',
- ], [
- 'account.required' => '短息渠道账号不能为空',
- ]);
- if ($validator->fails()) {
- return $validator->errors()->all();
- }
- $account = $request->input('account');//153132952
- $TrSmsModel = new TrSms();
- $result = $TrSmsModel->templateList($account);
- return $result;
- }
- //短信签名
- public function signList(Request $request)
- {
- //验参
- $validator = Validator::make($request->all(), [
- 'account' => 'required|numeric',
- ], [
- 'account.required' => '短息渠道账号不能为空',
- ]);
- if ($validator->fails()) {
- return $validator->errors()->all();
- }
- $account = $request->input('account');//153132952
- $TrSmsModel = new TrSms();
- $result = $TrSmsModel->signList($account);
- return $result;
- }
- //语音验证码
- public function voiceCode(Request $request)
- {
- //验参
- $validator = Validator::make($request->all(), [
- 'account' => 'required|numeric',
- 'mobile' => 'required',
- 'voiceCode' => 'required',
- ], [
- 'account.required' => '短息渠道账号不能为空',
- 'mobile.required' => 'mobile不能为空',
- 'voiceCode.required' => 'voiceCode不能为空',
- ]);
- if ($validator->fails()) {
- return $validator->errors()->all();
- }
- $account = $request->input('account');//153132952
- $mobile = $request->input('mobile');
- $voiceCode = $request->input('voiceCode');
- $TrSmsModel = new TrSms();
- $result = $TrSmsModel->voiceCode($account, $mobile, $voiceCode);
- return $result;
- }
- }
|