Smsset.php
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* Created by PhpStorm.
* User: ruidiudiu
* Date: 2019/4/3
* Time: 19:10
*/
namespace app\index\controller;
use app\admin\model\Validatetel;
use app\exception\Error;
use app\exception\Success;
class Smsset
{
public static function setSms($mobile,$style=1){
$url=config("sms.url");
$username=config("sms.username");
$password=config("sms.password");
$sendAPI = new setApi($url, $username, $password);
$random=rand(1000,9999);
session("iscode",$random);
$content="你的验证码为".$random.",如无操作请忽略【中关村绿色产业联盟】";
$data = array(
'content' => $content,//短信内容
'mobile' => $mobile,//手机号码
'productid' => '676767',//产品id
'xh' => ''//小号
);
$sendAPI->data = $data;//初始化数据包
$return = $sendAPI->sendSMS('POST');//GET or POST
if(explode(",",$return)[0]==1){
\app\index\service\Index::js("短信发送成功");
}else{
\app\index\service\Index::js($return);
}
}
}