修改短信发送

master
ELF 5 years ago
parent ef41dbfcee
commit 2195bb4c55

@ -345,7 +345,7 @@ class PublicController extends \Think\Controller
public function telsafecode($phone = '', $delay = 10, $flag = true) public function telsafecode($phone = '', $delay = 10, $flag = true)
{ {
$taskClient = new TaskClient(); $taskClient = new TaskClient();
$result = $taskClient->sendSms($phone, get_client_ip()); $result = $taskClient->sendSmsCode($phone, get_client_ip());
$data = []; $data = [];
if ($result['code'] == TaskClient::SUCCESS) { if ($result['code'] == TaskClient::SUCCESS) {
$data['status'] = 1; $data['status'] = 1;

@ -28,9 +28,27 @@ class TaskClient
return json_decode($result, true); return json_decode($result, true);
} }
public function sendSms($mobile, $clientIp, $type = 'common') public function sendSmsCode(string $mobile, string $clientIp)
{ {
return $this->post('/message/sms-send', ['mobile' => $mobile, 'type' => $type, 'client_ip' => $clientIp]); $options = ['type' => 'code', 'client_ip' => $clientIp];
return $this->sendSms($mobile, $options);
}
public function sendSmsContent(string $mobile, string $content)
{
$options = ['type' => 'content', 'content' => $content];
return $this->sendSms($mobile, $options);
}
public function sendSmsBatch(array $mobiles, string $content)
{
$options = ['type' => 'batch', 'content' => $content];
return $this->sendSms($mobiles, $options);
}
private function sendSms($mobile, array $options)
{
return $this->post('/message/sms-send', ['mobile' => $mobile, 'options' => $options]);
} }
public function checkSms($mobile, $code) public function checkSms($mobile, $code)

@ -220,7 +220,7 @@ class CommonController extends BaseController {
{ {
$phone = I('phone'); $phone = I('phone');
$taskClient = new TaskClient(); $taskClient = new TaskClient();
$result = $taskClient->sendSms($phone, get_client_ip()); $result = $taskClient->sendSmsCode($phone, get_client_ip());
$data = []; $data = [];
if ($result['code'] == TaskClient::SUCCESS) { if ($result['code'] == TaskClient::SUCCESS) {
$this->respondSuccess('发送成功'); $this->respondSuccess('发送成功');

@ -409,7 +409,7 @@ class SsgController extends BaseController {
{ {
$phone = I('phone'); $phone = I('phone');
$taskClient = new TaskClient(); $taskClient = new TaskClient();
$result = $taskClient->sendSms($phone, get_client_ip()); $result = $taskClient->sendSmsCode($phone, get_client_ip());
$data = []; $data = [];
if ($result['code'] == TaskClient::SUCCESS) { if ($result['code'] == TaskClient::SUCCESS) {
$data['status'] = 1; $data['status'] = 1;

@ -581,7 +581,7 @@ class UserController extends BaseController
public function telsafecode($phone = '', $delay = 10, $flag = true) public function telsafecode($phone = '', $delay = 10, $flag = true)
{ {
$taskClient = new TaskClient(); $taskClient = new TaskClient();
$result = $taskClient->sendSms($phone, get_client_ip()); $result = $taskClient->sendSmsCode($phone, get_client_ip());
$data = []; $data = [];
if ($result['code'] == TaskClient::SUCCESS) { if ($result['code'] == TaskClient::SUCCESS) {
$data['status'] = 1; $data['status'] = 1;

Loading…
Cancel
Save