|
@@ -0,0 +1,43 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\utils\Service\QiXunCloud;
|
|
|
+
|
|
|
+use app\utils\Service\Library;
|
|
|
+
|
|
|
+class SmsService extends Library
|
|
|
+{
|
|
|
+ protected $host = "http://sms.qxyai.com:9090";
|
|
|
+ private string $appKey = "3qumdN";
|
|
|
+ private string $appSecret = "rwL6cm";
|
|
|
+ private string $appCode = "1000";
|
|
|
+ private string $signName = "新邵县金蟾电子商务";// 新邵县金蟾电子商务有限公司
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送验证码
|
|
|
+ * @param string $mobile
|
|
|
+ * @param $code
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ public function send(string $mobile, $code)
|
|
|
+ {
|
|
|
+
|
|
|
+ $timestamp = ms_time();
|
|
|
+ $response = $this->postJson('/sms/batch/v1', [
|
|
|
+ 'sign' => md5("{$this->appKey}{$this->appSecret}{$timestamp}"),
|
|
|
+ 'timestamp' => $timestamp,
|
|
|
+ 'phone' => $mobile,
|
|
|
+ 'appcode' => $this->appCode,
|
|
|
+ 'appkey' => $this->appKey,
|
|
|
+ 'msg' => "【{$this->signName}】您的验证码是{$code},请妥善保管"
|
|
|
+ ]);
|
|
|
+ if (!$response) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (empty($response['code']) || $response['code'] != "00000"){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+}
|