接口请求的例子

string api_url = ConfigurationManager.AppSettings["api_url"].ToString();
                            string key = ConfigurationManager.AppSettings["app_key"].ToString();
                            string secret = ConfigurationManager.AppSettings["app_secret"].ToString();
                            string app_key = "app_key=" + key;
                            string app_secret = "app_secret=" + md5(secret);
                            string submitUrl = api_url + "?" + app_key + "&" + app_secret;//提交地址

                            //string aass = ReafHtml(submitUrl);
                            UTF8Encoding encoding = new UTF8Encoding();

                            string postData = "interface=" + xml;
                            byte[] data = encoding.GetBytes(postData);

                            HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(submitUrl);
                            myRequest.Method = "POST";


                            myRequest.ContentType = "application/x-www-form-urlencoded;";
                            myRequest.ContentLength = data.Length;
                            Stream newStream = myRequest.GetRequestStream();

                            // Send the data.
                            newStream.Write(data, 0, data.Length);
                            newStream.Close();

                            // Get response
                            HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
                            StreamReader reader = new StreamReader(myResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("utf-8"));
                            string content = reader.ReadToEnd();

原文地址:https://www.cnblogs.com/doosmile/p/2440857.html