Esempio n. 1
0
        /// <summary>
        /// 发送语音验证码
        /// </summary>
        /// <param name="auth_code">验证码, 一般为4~6位数字</param>
        /// <param name="mobile">目标手机号</param>
        /// <param name="rid">记录ID, 用于返回结果后的后续处理, 非必填</param>
        /// <param name="filter_nonnumber">是否过滤手机号中包含的非数字字符</param>
        /// <returns>发送结果</returns>
        public override SMSResponse sendVoiceAuth(string auth_code, string mobile, string rid, bool filter_nonnumber)
        {
            if (service_key.isNull())
            {
                return(SMSResponse.errorNotInitialized());
            }
            if (auth_code.isNull())
            {
                return(SMSResponse.custom(9900, "传入内容不能为空"));
            }
            if (filter_nonnumber)
            {
                mobile = mobile.getOnlyNumber();
            }
            if (!mobile.isPhoneNumber())
            {
                return(SMSResponse.custom(9901, "手机号传入有误"));
            }
            var sb = new StringBuilder();

            sb.Append("apikey=");
            sb.Append(service_key);
            sb.Append("&mobile=");
            sb.Append(mobile);
            sb.Append("&code=");
            sb.Append(auth_code);
            if (!rid.isNull())
            {
                sb.Append("&uid=" + rid);
            }
            var response = post(Urls.urlAuthCodeVoice(), sb.ToString());

            return(getResponse(response));
        }