public HttpResponseMessage SendSignUpSMS([FromBody] string mobile) { if (string.IsNullOrWhiteSpace(mobile)) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, MakeMessage("手机号不能为空"))); } string code = WebFunctions.GetRandomNumber(4); string content = "注册验证码(" + code + "),用于验证(" + ConstValue.SmsEffectiveTime.ToString() + "分钟内有效)。请勿向任何人提供您收到的验证码"; string result = string.Empty; try { result = SmsSender.Send(mobile, content); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, MakeMessage("发送失败:" + ex.Message))); } SMSLog newSms = new SMSLog() { code = code, phone = mobile, smsType = ConstValue.SmsType.SignUp, status = ConstValue.SmsStatus.Pending, textContent = content, createTime = DateTime.Now, result = result, }; DB.SMSLog.Add(newSms); DB.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, MakeMessage("已发送"))); }