コード例 #1
0
ファイル: Program.cs プロジェクト: cuiweigang/Yun
        /// <summary>
        /// 语音验证码
        /// </summary>
        public static void VoiceVerify()
        {
            string ret = null;

            CCPRestSDK api = new CCPRestSDK();

            bool isInit = api.init("sandboxapp.cloopen.com", "8883");

            api.setAccount("8a48b55146472691014689aa664f2", "f1258a0cc1a7492aa55e9eafb4b05");
            api.setAppId("8a48b5514647269101468a07a0d42");

            try
            {
                if (isInit)
                {
                    Dictionary <string, object> retData = api.VoiceVerify("手机号", "123456", null, "3", null);
                    ret = getDictionaryData(retData);
                }
                else
                {
                    ret = "初始化失败";
                }
            }
            catch (Exception exc)
            {
                ret = exc.Message;
            }
            finally
            {
                Console.WriteLine(ret);
            }
        }
コード例 #2
0
        /// <summary>
        /// 海峡竞技短信验证码推送
        /// author:白尚德
        /// </summary>
        /// <param name="phone">推送手机号码</param>
        /// <param name="val">验证码</param>
        /// <param name="type">1短信,2语音</param>
        /// <param name="templates">推送模板</param>
        public bool StraitMessageCode(string phone, string val, int type, string templates = "377916")
        {
            Infrastructure.Sdk.CCPRestSDK api = new CCPRestSDK();
            /*服务器地址,服务器端口*/
            bool   bIsInit   = api.init("app.cloopen.com", "8883");
            string strRet    = string.Empty;
            string strResult = string.Empty;

            /*主账号,主账号令牌,如果主页更换了token需要在这里更改令牌*/
            api.setAccount("8aaf070857acf7a70157adee1554019f", "587ffc830e3d46c59e70f907f50e78e0");
            api.setAppId("8aaf070866f7197701670ab5393309e7"); /*应用ID*/
            string template = "377916";

            try
            {
                Dictionary <string, object> RetData = null;
                if (type == 1) //短信
                {
                    /*手机号码,短信模板,验证码*/
                    RetData = api.SendTemplateSMS(phone, template, new string[] { val, "1" });
                }
                else
                {   /*手机号码,验证码,显示主叫号码,重复次数,回调地址*/
                    RetData = api.VoiceVerify(phone, val, null, "3", null);
                }
                //推送短信/电话
                strRet = api.getDictionaryData(RetData);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                string[] str_Temp = strRet.Split(';');
                strResult = str_Temp[0];
                strResult = strResult.Substring(strResult.IndexOf("=") + 1);
            }
            if (strResult != "000000")
            {
                //推送失败
                return(false);
            }
            return(true);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="mobile"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static ReturnResult SendVoice(string mobile, string data)
        {
            if (!ValidateUtil.IsMobile(mobile))
            {
                return(new ReturnResult {
                    Msg = "错误的手机号", Code = 1
                });
            }
            try
            {
                CCPRestSDK api = new CCPRestSDK();
                //ip格式如下,不带https://
                bool isInit = api.init(url, port);
                api.setAccount(accountSid, token);
                api.setAppId(appId);
                api.enabeLog(true);

                if (isInit)
                {
                    Dictionary <string, object> retData = api.VoiceVerify(mobile, data, "", "3", "");
                    if (retData["statusCode"].ToString() == "000000")
                    {
                        return(new ReturnResult {
                            Msg = "发送成功", Code = 0
                        });
                    }
                    else
                    {
                        return(new ReturnResult {
                            Msg = "发送失败", Code = 1
                        });
                    }
                }
                else
                {
                    return(new ReturnResult {
                        Msg = "短信模块初始化失败", Code = 1
                    });
                }
            }
            catch { return(new ReturnResult {
                    Msg = "发送失败", Code = 1
                }); }
        }