protected void Page_Load(object sender, EventArgs e) { string ret = null; CCPRestSDK.CCPRestSDK api = new CCPRestSDK.CCPRestSDK(); //ip格式如下,不带https:// bool isInit = api.init("sandboxapp.cloopen.com", "8883"); api.setAccount(主帐号, 主帐号令牌); api.setAppId(应用ID); try { if (isInit) { Dictionary<string, object> retData = api.VoiceVerify(接听号码, 验证码内容, 接听侧显示号码, 播放次数, 语音验证码状态通知回调地址); ret = getDictionaryData(retData); } else { ret = "初始化失败"; } } catch (Exception exc) { ret = exc.Message; } finally { Response.Write(ret); } }
private static string AppId = "8a48b55149754f8001497950ac0301a7"; //APP ID #region VoiceVerify 发送语音验证码 /// <summary> /// 发送语音验证码 /// </summary> /// <param name="verifyCode"></param> /// <param name="phoneNum"></param> /// <returns></returns> public static VoiceResult SendVoiceVerify(string verifyCode, string phoneNum) { var model = new VoiceResult(); var ccpControl = new CCPRestSDK.CCPRestSDK(); bool isInit = ccpControl.init(ApiHost, ApiPort); ccpControl.setAccount(Account, AccountToken); ccpControl.setAppId(AppId); model.Status = false; try { if (isInit) { var oResult = ccpControl.VoiceVerify(phoneNum, verifyCode, "4006006815", "3", "http://app.i200.cn/API/VoiceVerify.ashx"); if (oResult.ContainsKey("statusCode")) { model.StatusCode = oResult["statusCode"].ToString().Trim(); if (oResult.ContainsKey("data")) { var oItem = (Dictionary <string, object>)oResult["data"]; if (oItem.ContainsKey("VoiceVerify")) { var oList = (Dictionary <string, object>)oItem["VoiceVerify"]; if (oList.ContainsKey("callSid")) { model.CallSid = oList["callSid"].ToString().Trim(); } if (oList.ContainsKey("dateCreated")) { model.DateCreated = oList["dateCreated"].ToString().Trim(); } } } model.Status = true; } } else { model.StatusCode = "-1"; } } catch (Exception ex) { model.StatusCode = ex.ToString(); } return(model); }