PayUserInfoEx getPUI(string theExInfo, int the3rdUsrID) { var pui = new PayUserInfoEx(); pui.UserId = theUserId; pui.typeUser = requestPack.typeUser; pui.the3rdUsrID = utils.KeyInt2Uint(the3rdUsrID); pui.InfoExt = theExInfo; return(pui); }
void Pay360() { const string urlLogin = "******"; var cache = new PersonalCacheStruct <PayUserInfoEx>(); PayUserInfoEx pui = cache.FindKey(theUserId.ToString()); string json = ""; returnJson jr = null; int happyIndex = -1; if (pui == null) { // 回调后。 string sendURL = urlLogin + HttpUtility.UrlEncode("access_token", Encoding.UTF8) + "=" + HttpUtility.UrlEncode(requestPack.token, Encoding.UTF8) + "&" + HttpUtility.UrlEncode("fields=id,name,avatar,sex,area", Encoding.UTF8); try { json = utils.HttpPost(sendURL, ""); jr = JsonHelper.ParseFromJson <returnJson>(json); happyIndex = getHappyIndex(requestPack.typeUser, jr.id); pui = getPUI(json, happyIndex); cache.Add(pui); } catch (System.Exception e) { json = "{}"; jr = JsonHelper.ParseFromJson <returnJson>(json); ConsoleLog.showErrorInfo(0, e.Message); } } else { json = pui.InfoExt; jr = JsonHelper.ParseFromJson <returnJson>(json); happyIndex = getHappyIndex(requestPack.typeUser, jr.id); } if (json == "{}") { responsePack.errorCode = (byte)Response1005Pack.EnumErrorCode.token_error; } else { responsePack.typeUser = requestPack.typeUser; responsePack.result = getReturnInfo(jr); responsePack.the3rdUserId = (uint)happyIndex; responsePack.errorCode = (byte)Response1005Pack.EnumErrorCode.ok; } }
void doAdd_PayUserInfo(string parm) { string[] parmSS = parm.Split(','); uint the3rdID = uint.Parse(parmSS[0]); var cache = new PersonalCacheStruct <PayUserInfoEx>(); PayUserInfoEx pui = cache.FindKey(the3rdID.ToString()); if (null == pui) { pui = new PayUserInfoEx(); pui.the3rdUsrID = the3rdID; pui.UserId = int.Parse(parmSS[1]); pui.identify = the3rdID.ToString(); pui.the3rdUsrName = parmSS[2]; pui.typeUser = parmSS[3]; Action1005.returnJson rj = new Action1005.returnJson(); rj.id = the3rdID.ToString(); rj.name = pui.the3rdUsrName; int id = Action1005.getHappyIndex(pui.typeUser, the3rdID.ToString()); pui.the3rdUsrID = (uint)id; pui.InfoExt = JsonHelper.GetJson <Action1005.returnJson>(rj); cache.Add(pui); } }
void PayBaiDu() { int appID = 6368606; var secretkey = "NuWnKNHmDndw3HxuGT8ovxfgSp8dbGDq"; var url = "http://querysdkapi.91.com/CpLoginStateQuery.ashx"; var accessToken = requestPack.token; //客户端SDK返回的登陆令牌 var sign = Utility.Encrypt_MD5_UTF8(appID + accessToken + secretkey); //签名 var cache = new PersonalCacheStruct <PayUserInfoEx>(); PayUserInfoEx pui = cache.FindKey(theUserId.ToString()); if (null == pui) { var postdata = string.Empty; List <string> pairs = new List <string>(); pairs.Add(string.Format("{0}={1}", "AppID", appID)); pairs.Add(string.Format("{0}={1}", "AccessToken", accessToken)); pairs.Add(string.Format("{0}={1}", "Sign", sign)); postdata = string.Join("&", pairs.ToArray()); //请求接口 var returnValue = Utility.ReceiveResponse(url, postdata, System.Text.Encoding.UTF8); //解析json数据 var result = JsonConvert.DeserializeAnonymousType(returnValue, new { AppID = 0, ResultCode = 0, ResultMsg = string.Empty, Sign = string.Empty, Content = string.Empty }); if (result == null)//请求超时或服务器错误的情况下 { //Response.Write("接口请求出错!"); responsePack.errorCode = (byte)Response1005Pack.EnumErrorCode.bd_result_error; return; } //获取返回数据 if (result.ResultCode == 1 && result.Sign == Utility.Encrypt_MD5_UTF8(appID + result.ResultCode.ToString() + HttpUtility.UrlDecode(result.Content) + secretkey))//成功 { //业务处理 //获取数据,业务处理 var content = HttpUtility.UrlDecode(result.Content);//Content参数需要UrlDecode // 【BASE64解码--》JSON解析】 var item = JsonConvert.DeserializeObject <LoginStateReturn>(Utility.Base64StringDecode(content)); if (item != null && item.UID > 0) { int index = getHappyIndex(requestPack.typeUser, item.UID.ToString()); //业务处理 responsePack.result = getReturnInfo(item.UID.ToString(), "", ""); responsePack.the3rdUserId = utils.KeyInt2Uint(index); responsePack.errorCode = (byte)Response1005Pack.EnumErrorCode.ok; pui = getPUI(responsePack.result, index); cache.Add(pui); } else { responsePack.errorCode = (byte)Response1005Pack.EnumErrorCode.bd_item_error; } //Response.Write("接口处理成功!"); return; } else//失败 { //Response.Write("接口请求出错!"); responsePack.errorCode = (byte)Response1005Pack.EnumErrorCode.bd_token_error; return; } } else { responsePack.result = pui.InfoExt; responsePack.the3rdUserId = pui.the3rdUsrID; responsePack.errorCode = (byte)Response1005Pack.EnumErrorCode.ok; } }