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 void Main(string[] args)
        {
            Console.WriteLine("*****开始发送******");

            JSMSClient client = new JSMSClient(app_key, master_secret);

            // 验证 API
            // API文档地址 http://docs.jiguang.cn/jsms/server/rest_api_jsms/#api_2
            string       msg_id    = "227effab-b00c-4569-8021-220a036b7ae6";
            ValidPayload codes     = new ValidPayload("121806");
            String       codesjson = codes.ToJson(codes);

            Console.WriteLine(codesjson);
            client._SMSClient.validCodes(codes, msg_id);
            Console.ReadLine();
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            Console.WriteLine("*****开始发送******");

            JSMSClient client = new JSMSClient(app_key, master_secret);

            // 语音短信验证码 API
            // API文档地址 http://docs.jiguang.cn/jsms/server/rest_api_jsms/#api_1

            Voice_codesPayload voice_codes     = new Voice_codesPayload("134888888888", 60);
            String             voice_codesjson = voice_codes.ToJson(voice_codes);

            Console.WriteLine(voice_codesjson);
            client._SMSClient.sendVoice_codes(voice_codesjson);

            Console.ReadLine();
        }
Exemple #4
0
        /// <summary>
        /// 验证验证码
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="masterSecret"></param>
        /// <param name="code"></param>
        /// <param name="msgId"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public static bool Validate(string appKey, string masterSecret, string code, string msgId, ref string errMsg)
        {
            bool       retBool = false;
            JSMSClient client  = new JSMSClient(appKey, masterSecret);

            string       msg_id = msgId;
            ValidPayload codes  = new ValidPayload(code);

            String          codesjson = codes.ToJson(codes);
            ResponseWrapper ret       = client._SMSClient.ValidCodes(codes, msg_id);

            retBool = ret.responseCode == HttpStatusCode.OK;

            if (!retBool)
            {
                errMsg = ret.ResponseContent;
            }
            return(retBool);
        }
Exemple #5
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="appKey"></param>
        /// <param name="masterSecret"></param>
        /// <param name="mobile">手机</param>
        /// <param name="tempId">模版id</param>
        /// <param name="msgId">短信码id</param>
        /// <returns></returns>
        public static bool Send(string appKey, string masterSecret, string mobile, int tempId, ref string msgId)
        {
            bool       retBool = false;
            JSMSClient client  = new JSMSClient(appKey, masterSecret);

            SMSPayload codes     = new SMSPayload(mobile, tempId);
            String     codesjson = codes.ToJson(codes);

            ResponseWrapper ret = client._SMSClient.SendCodes(codesjson);

            retBool = ret.responseCode == HttpStatusCode.OK;

            if (retBool)
            {
                SendSmsInfo info = JsonConvert.DeserializeObject <SendSmsInfo>(ret.ResponseContent);
                msgId = info.msg_id;
            }
            return(retBool);
        }
Exemple #6
0
        public static void Main(string[] args)
        {
            Console.WriteLine("*****开始发送******");

            JSMSClient client = new JSMSClient(app_key, master_secret);

            // 短信验证码 API
            // API文档地址 http://docs.jiguang.cn/jsms/server/rest_api_jsms/#api

            SMSPayload codes     = new SMSPayload("134888888888", 1);
            String     codesjson = codes.ToJson(codes);

            Console.WriteLine(codesjson);
            ResponseWrapper result = client._SMSClient.sendCodes(codesjson);

            Console.WriteLine("result.responseContent");
            Console.WriteLine(result.responseContent);

            Console.ReadLine();
        }
        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);
            }
        }
Exemple #8
0
        public static void Main(string[] args)
        {
            Console.WriteLine("*****开始发送******");

            JSMSClient client = new JSMSClient(app_key, master_secret);

            // 短信验证码 API
            // API文档地址 http://docs.jiguang.cn/jsms/server/rest_api_jsms/#api_3

            Dictionary <string, string> temp_para = new Dictionary <string, string>();;

            temp_para.Add("codes", "1914");
            string para = temp_para.ToString();

            Console.WriteLine(para);

            SMSPayload codes     = new SMSPayload("134888888888", 9890, temp_para);
            String     codesjson = codes.ToJson(codes);

            Console.WriteLine(codesjson);
            client._SMSClient.sendMessages(codesjson);

            Console.ReadLine();
        }