后台代码调用接口。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了后台代码调用接口。相关的知识,希望对你有一定的参考价值。

    /// <summary>
        /// Get Post
        /// </summary>
        /// <param name="url"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static string PostMoths(string url, string param)
        {
            string strURL = url;
            System.Net.HttpWebRequest request;
            request = (System.Net.HttpWebRequest)WebRequest.Create(strURL);
            request.Method = "POST";
            request.ContentType = "application/json;charset=UTF-8";
            string paraUrlCoded = param;
            byte[] payload;
            payload = System.Text.Encoding.UTF8.GetBytes(paraUrlCoded);
            request.ContentLength = payload.Length;
            Stream writer = request.GetRequestStream();
            writer.Write(payload, 0, payload.Length);
            writer.Close();
            System.Net.HttpWebResponse response;
            response = (System.Net.HttpWebResponse)request.GetResponse();
            System.IO.Stream s;
            s = response.GetResponseStream();
            string StrDate = "";
            string strValue = "";
            StreamReader Reader = new StreamReader(s, Encoding.UTF8);
            while ((StrDate = Reader.ReadLine()) != null)
            {
                strValue += StrDate + "\r\n";
            }
            return strValue;
        }

 

以上是关于后台代码调用接口。的主要内容,如果未能解决你的问题,请参考以下文章

替换或删除后台堆栈上现有片段的代码不起作用

java 后台框架 支持APP接口调用 APP后台 手机后台框架java springmvc myb

无法通过接口获取与片段通信的活动

JSONP调用MVC后台接口

如何从后台弹出片段

做前后台代码分离项目的一些好的习惯