public static bool VcodeIsSuccess(string session, string sig, string token, string scene) { bool result = false; //YOUR ACCESS_KEY、YOUR ACCESS_SECRET请替换成您的阿里云accesskey id和secret IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", "", ""); IAcsClient client = new DefaultAcsClient(profile); DefaultProfile.AddEndpoint("cn-hangzhou", "cn-hangzhou", "jaq", "jaq.aliyuncs.com"); AfsCheckRequest request = new AfsCheckRequest(); request.Platform = 3; //必填参数,请求来源: 1:Android端; 2:iOS端; 3:PC端及其他 request.Session = session; // 必填参数,从前端获取,不可更改 request.Sig = sig; // 必填参数,从前端获取,不可更改 request.Token = token; // 必填参数,从前端获取,不可更改 request.Scene = scene; // 必填参数,从前端获取,不可更改 try { AfsCheckResponse response = client.GetAcsResponse(request); // TODO result = (bool)response.Data; } catch (Exception ex) { //Console.WriteLine(e.ToString()); //throw new Exception(ex.Message); result = false; } return(result); }
public ActionResult TestCode(string username, string password) { IAcsClient client = null; IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", ConstString.KeyId, ConstString.KeySecret); client = new DefaultAcsClient(profile); DefaultProfile.AddEndpoint("cn-hangzhou", "cn-hangzhou", "Jaq", "jaq.aliyuncs.com"); AfsCheckRequest request = new AfsCheckRequest(); request.Platform = 3; //必填参数,请求来源: 1:Android端; 2:iOS端; 3:PC端及其他 request.Session = Request.Params["csessionid"]; // 必填参数,从前端获取,不可更改 request.Sig = Request.Params["sig"]; // 必填参数,从前端获取,不可更改 request.Token = Request.Params["token"]; // 必填参数,从前端获取,不可更改 request.Scene = Request.Params["scene"]; // 必填参数,从前端获取,不可更改 ResultView <string> result = new ResultView <string>(); try { AfsCheckResponse response = client.GetAcsResponse(request); if (response.ErrorCode == null || response.ErrorCode.Value == 0) { //写正常业务逻辑 result = (new ResultView <string> { Flag = true, Message = "登录成功" }); } else { result = (new ResultView <string> { Flag = false, Message = "Error:" + response.ErrorMsg }); } } catch (Exception e) { //验证不通过,给出错误提示 return(Json(new ResultView <string> { Flag = false, Message = "验证码错误" + e.Message })); } return(Json(result)); }