zoukankan      html  css  js  c++  java
  • 接口请求的例子

    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();

  • 相关阅读:
    C++之STL总结精华笔记
    [转]asp.net使用uploadify上传出现的IO Error问题
    $.post()参数及返回值
    用CSS3.0画圆
    C# 用代码返回上一页
    用js获取cookie
    html页面的局部刷新
    在Asp.Net中使用amChart统计图
    内存中DataTable去除重复行
    .net中对HTTP请求的两种请求:Get和Post的操作
  • 原文地址:https://www.cnblogs.com/doosmile/p/2440857.html
Copyright © 2011-2022 走看看