/// <summary> /// 将参数绑定到url /// </summary> /// <param name="asyncUrl"></param> /// <param name="data"></param> /// <returns></returns> private static string GetUrl(string asyncUrl, string secret, string action, DiscuzParam[] parameters) { List<DiscuzParam> list = new List<DiscuzParam>(parameters); list.Add(DiscuzParam.Create("time", DiscuzMethodes.Time())); list.Add(DiscuzParam.Create("action", action)); list.Sort(); StringBuilder values = new StringBuilder(); foreach (DiscuzParam param in list) { if (!string.IsNullOrEmpty(param.Value)) values.Append(param.ToString()); } values.Append(secret); byte[] md5_result = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(values.ToString())); StringBuilder sig_builder = new StringBuilder(); foreach (byte b in md5_result) sig_builder.Append(b.ToString("x2")); list.Add(DiscuzParam.Create("sig", sig_builder.ToString())); StringBuilder builder = new StringBuilder(); for (int i = 0; i < list.Count; i++) { if (i > 0) builder.Append("&"); builder.Append(list[i].ToEncodedString()); } return string.Format("{0}?{1}", asyncUrl, builder.ToString()); }
//public static string SetCookie(string name, string value, strin) /// <summary> /// 发送请求 /// </summary> /// <param name="action"></param> /// <param name="data"></param> private static void SendRequest(string action, DiscuzParam[] data) { ApplicationInfoCollection appCollection = GetAsyncTarget(action); foreach (ApplicationInfo appInfo in appCollection) { new ProcessAsync(GetUrl(appInfo.SyncUrl, appInfo.Secret, action, data)).Enqueue(); } }