public static bool IsPassVerification(string msgid, string VerificationCode, string appid) { dm_basesettingEntity dm_BasesettingEntity = new DM_BaseSettingService().GetEntityByCache(appid); if (dm_BasesettingEntity.IsEmpty()) { throw new Exception("参数错误!"); } JSMSClient jsmsClient = new JSMSClient(dm_BasesettingEntity.jg_appkey, dm_BasesettingEntity.jg_appsecret); HttpResponse httpResponse = jsmsClient.IsCodeValid(msgid, VerificationCode); if (httpResponse.StatusCode != HttpStatusCode.OK) { SmsVerifityMsg smsVerifityMsg = JsonConvert.JsonDeserialize <SmsVerifityMsg>(httpResponse.Content); if (!smsVerifityMsg.is_valid) { throw new Exception(GetErrorMessage(smsVerifityMsg.error)); } return(smsVerifityMsg.is_valid); //throw new Exception("短信接口验证错误" + httpResponse.Content); //return false; } else { SmsVerifityMsg smsVerifityMsg = JsonConvert.JsonDeserialize <SmsVerifityMsg>(httpResponse.Content); if (!smsVerifityMsg.is_valid) { throw new Exception(GetErrorMessage(smsVerifityMsg.error)); } return(smsVerifityMsg.is_valid); } }
public static string SendSms(string phone, string appid) { dm_basesettingEntity dm_BasesettingEntity = new DM_BaseSettingService().GetEntityByCache(appid); if (dm_BasesettingEntity.IsEmpty()) { throw new Exception("参数错误!"); } JSMSClient jsmsClient = new JSMSClient(dm_BasesettingEntity.jg_appkey, dm_BasesettingEntity.jg_appsecret); HttpResponse httpResponse = jsmsClient.SendCode(phone, int.Parse(dm_BasesettingEntity.sms_template_id), int.Parse(dm_BasesettingEntity.sms_sign_id)); if (httpResponse.StatusCode != HttpStatusCode.OK) { SmsVerifityMsg smsVerifityMsg = JsonConvert.JsonDeserialize <SmsVerifityMsg>(httpResponse.Content); throw new Exception(GetErrorMessage(smsVerifityMsg.error)); } else { SmsMsg smsMsg = JsonConvert.JsonDeserialize <SmsMsg>(httpResponse.Content); return(smsMsg.msg_id); } }