|
@@ -68,47 +68,72 @@ class Sms Extends Model
|
|
|
public static function accessKeyClient($event, $mobile, $num)
|
|
|
{
|
|
|
|
|
|
-// $ip = request()->ip();
|
|
|
-// self::create(['event' => $event, 'mobile' => $mobile, 'code' => $num, 'ip' => $ip]);
|
|
|
-// $info['Code'] = "OK";
|
|
|
-// return $info;
|
|
|
-
|
|
|
+ $statusStr = array(
|
|
|
+ "0" => "短信发送成功",
|
|
|
+ "-1" => "参数不全",
|
|
|
+ "-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!",
|
|
|
+ "30" => "密码错误",
|
|
|
+ "40" => "账号不存在",
|
|
|
+ "41" => "余额不足",
|
|
|
+ "42" => "帐户已过期",
|
|
|
+ "43" => "IP地址限制",
|
|
|
+ "50" => "内容含有敏感词"
|
|
|
+ );
|
|
|
+ $code = $num;
|
|
|
+ $smsapi = "http://api.smsbao.com/";
|
|
|
+ $user = "dy18747027321"; //短信平台帐号
|
|
|
+ $pass = md5("5201314asd"); //短信平台密码
|
|
|
+ $content="您的验证码".$code.",该验证码5分钟内有效,请勿泄漏于他人!";//要发送的短信内容
|
|
|
+ $phone = $mobile;
|
|
|
+ $sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content);
|
|
|
+ $result =file_get_contents($sendurl) ;
|
|
|
+ //$a = $statusStr[$result];
|
|
|
+ if ($result == 0){
|
|
|
+ $ip = request()->ip();
|
|
|
+ Sms::create(['event' => $event, 'mobile' => $mobile, 'code' => $num, 'ip' => $ip]);
|
|
|
+ $array['Code'] = "OK";
|
|
|
+ return $array;
|
|
|
+ }else{
|
|
|
+ $array['Code'] = 'error';
|
|
|
+ return $array;
|
|
|
+ }
|
|
|
|
|
|
- $ali_accesskey = Config::get_values('ali_accesskey');
|
|
|
- $ali_accesskey_secret = Config::get_values('ali_accesskey_secret');
|
|
|
- $templateCode = Config::get_values('templateCode');
|
|
|
- AlibabaCloud::accessKeyClient($ali_accesskey, $ali_accesskey_secret)
|
|
|
- ->regionId('cn-hangzhou')
|
|
|
- ->asDefaultClient();
|
|
|
|
|
|
- try {
|
|
|
- $result = AlibabaCloud::rpc()
|
|
|
- ->product('Dysmsapi')
|
|
|
- // ->scheme('https') // https | http
|
|
|
- ->version('2017-05-25')
|
|
|
- ->action('SendSms')
|
|
|
- ->method('POST')
|
|
|
- ->host('dysmsapi.aliyuncs.com')
|
|
|
- ->options([
|
|
|
- 'query' => [
|
|
|
- 'PhoneNumbers' => $mobile,
|
|
|
- 'SignName' => '杭州小胖脸科技有限公司',
|
|
|
- 'TemplateCode' => $templateCode,
|
|
|
- 'TemplateParam' => '{"code":' . $num . '}',
|
|
|
- ],
|
|
|
- ])
|
|
|
- ->request();
|
|
|
- $info = $result->toArray();
|
|
|
- if ($info['Code'] == 'OK') {
|
|
|
- $ip = request()->ip();
|
|
|
- Sms::create(['event' => $event, 'mobile' => $mobile, 'code' => $num, 'ip' => $ip]);
|
|
|
- }
|
|
|
- return $info;
|
|
|
- } catch (ClientException $e) {
|
|
|
- echo $e->getErrorMessage() . PHP_EOL;
|
|
|
- } catch (ServerException $e) {
|
|
|
- echo $e->getErrorMessage() . PHP_EOL;
|
|
|
- }
|
|
|
+// $ali_accesskey = Config::get_values('ali_accesskey');
|
|
|
+// $ali_accesskey_secret = Config::get_values('ali_accesskey_secret');
|
|
|
+// $templateCode = Config::get_values('templateCode');
|
|
|
+// AlibabaCloud::accessKeyClient($ali_accesskey, $ali_accesskey_secret)
|
|
|
+// ->regionId('cn-hangzhou')
|
|
|
+// ->asDefaultClient();
|
|
|
+//
|
|
|
+// try {
|
|
|
+// $result = AlibabaCloud::rpc()
|
|
|
+// ->product('Dysmsapi')
|
|
|
+// // ->scheme('https') // https | http
|
|
|
+// ->version('2017-05-25')
|
|
|
+// ->action('SendSms')
|
|
|
+// ->method('POST')
|
|
|
+// ->host('dysmsapi.aliyuncs.com')
|
|
|
+// ->options([
|
|
|
+// 'query' => [
|
|
|
+// 'PhoneNumbers' => $mobile,
|
|
|
+// 'SignName' => '杭州小胖脸科技有限公司',
|
|
|
+// 'TemplateCode' => $templateCode,
|
|
|
+// 'TemplateParam' => '{"code":' . $num . '}',
|
|
|
+// ],
|
|
|
+// ])
|
|
|
+// ->request();
|
|
|
+// $info = $result->toArray();
|
|
|
+// if ($info['Code'] == 'OK') {
|
|
|
+// $ip = request()->ip();
|
|
|
+// Sms::create(['event' => $event, 'mobile' => $mobile, 'code' => $num, 'ip' => $ip]);
|
|
|
+// }
|
|
|
+// return $info;
|
|
|
+// } catch (ClientException $e) {
|
|
|
+// echo $e->getErrorMessage() . PHP_EOL;
|
|
|
+// } catch (ServerException $e) {
|
|
|
+// echo $e->getErrorMessage() . PHP_EOL;
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
|