Smsset.php 1.1 KB
<?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);
        }
    }
}