string shujuid ="";//这里为url的ID,自己去获取数据
//百度api推送 start
string formUrl = "http://data.zz.baidu.com/urls?site=https://www.2wx.com&token=xxxxxxxxxxxxx";
string formData = "https://www.2wx.com/view-"+shujuid+".html";
byte[] postData = System.Text.Encoding.UTF8.GetBytes(formData);
// 设置提交的相关参数
System.Net.HttpWebRequest request = System.Net.WebRequest.Create(formUrl) as System.Net.HttpWebRequest;
System.Text.Encoding myEncoding = System.Text.Encoding.UTF8;
request.Method = "POST";
request.KeepAlive = false;
request.AllowAutoRedirect = true;
request.ContentType = "text/plain";
request.UserAgent = "curl/7.12.1";
request.ContentLength = postData.Length;
// 提交请求数据
System.IO.Stream outputStream = request.GetRequestStream();
outputStream.Write(postData, 0, postData.Length);
outputStream.Close();
System.Net.HttpWebResponse response;
System.IO.Stream responseStream;
System.IO.StreamReader reader;
string srcString;
response = request.GetResponse() as System.Net.HttpWebResponse;
responseStream = response.GetResponseStream();
reader = new System.IO.StreamReader(responseStream, System.Text.Encoding.GetEncoding("UTF-8"));
srcString = reader.ReadToEnd();
string resultapi = srcString; //返回值赋值
reader.Close();
Response.Write(resultapi);
//百度api推送 结束
ASPX.NET百度API推送URL范例,自己测试可用。