/***
* 个人中心 发送验证码
*/
public function send_code(){
//$mobile=*****************;
$mobile=input('post.mobile');
if (empty($mobile)) {
return json_encode(array('code' => 1 , 'msg' => '请填写信息' , "data" =>''));
}else{
$data=Db::name('user')->where('mobile',$mobile)->find();
$code=rand(100000,999999);
$time=5;
$statusStr = array(
"0" => "短信发送成功",
"-1" => "参数不全",
"-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!",
"30" => "密码错误",
"40" => "账号不存在",
"41" => "余额不足",
"42" => "帐户已过期",
"43" => "IP地址限制",
"50" => "内容含有敏感词"
);
$smsapi = "http://www.smsbao.com/"; //短信网关
$user = "*****"; //短信平台帐号
$pass = md5("*********"); //短信平台密码
$content="【公司名称】您的验证码是".$code.",在".$time."分钟内有效,若非本人操作请忽略此消息。";//要发送的短信内容
$phone = $mobile;
$sendurl = $smsapi."sms?u=".$user."&p=".$pass."&m=".$phone."&c=".urlencode($content);
$result =file_get_contents($sendurl);
$arr['mobile']=$mobile;
$arr['code']=$code;
$arr['time']=time();
$add = Db::name('code')->insert($arr);
return json_encode(array('code' => 0 , 'msg' => '发送成功' , "data" =>''));
// return json_encode($msg);
}
}