C#百度推送post提交

 public static string PostUrl()
        {
            string postData = "http://www.591mf.top";
            string urls = "http://data.zz.baidu.com/urls?site=www.591mf.top&token=WWzZXVyX4X0BBK";
            // 要发放的数据

            byte[] byteArray = Encoding.UTF8.GetBytes(postData);
            HttpWebRequest objWebRequest = (HttpWebRequest)WebRequest.Create(urls);
            //  objWebRequest.ServicePoint.Expect100Continue = false;
            objWebRequest.Method = "POST";
            objWebRequest.ContentType = "text/plain";
            objWebRequest.Host = "data.zz.baidu.com";
            objWebRequest.UserAgent = "curl/7.12.1";
            objWebRequest.ContentType = "text/plain";
            //objWebRequest.ContentLength = 83;

            objWebRequest.ContentLength = byteArray.Length;
            Stream newStream = objWebRequest.GetRequestStream();
            // Send the data.
            newStream.Write(byteArray, 0, postData.Length); //写入参数
            newStream.Close();
            HttpWebResponse response = (HttpWebResponse)objWebRequest.GetResponse();
            StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.Default);
            string textResponse = sr.ReadToEnd();

            return textResponse;
        }

 

上一篇:php – 自动POST数据方法


下一篇:js图片压缩+ajax上传