POST /hospital/hospitalsearch/list.json HTTP/1.1
User-Agent: android
version: 2.34
appid: p_android_weiyi
version-type: patient
os-token-id: 7c5280e3-23cf-466b-afad-d8d6edb87f4a
sign: UzzEyNJMwZlhR7pet6Swt0SxhQFxVcsqLFhki1MN4uWLoeKnCl5gIxpb3dwgK1v5MLLTaSwSsGWsodbJn5/GMaHhOUf6Wk7T3hJIei+Qm+VWQ/V2fv0VbEjl4ijKI+Fgh7JslaLDvI5CP9PONBEV6I/9iVzkGD1OGSOAHYNcT5g=
Content-Type: application/json
Content-Length: 71
Host: mobileservice.guahao.cn
Connection: Keep-Alive
Expect: 100-continue
{"pageNo":1,"pageSize":20,"sort":"region_sort","area":"79","haoyuan":2}
c#代码
string strUrl = "http://mobileservice.guahao.cn/hospital/hospitalsearch/list.json";
HttpWebRequest httpWebRequest = null;
HttpWebResponse httpWebRespones = null;
string strHtml;
httpWebRequest = (HttpWebRequest)WebRequest.Create(strUrl);
httpWebRequest.AllowAutoRedirect = true;
httpWebRequest.UserAgent = "android";
httpWebRequest.Method = "post";
httpWebRequest.KeepAlive = true;
httpWebRequest.AllowAutoRedirect = false;
httpWebRequest.ContentType = "application/json";
httpWebRequest.Headers.Add("version", "2.34");
httpWebRequest.Headers.Add("appid", "p_android_weiyi");
httpWebRequest.Headers.Add("version-type", "patient");
httpWebRequest.Headers.Add("sign", "UzzEyNJMwZlhR7pet6Swt0SxhQFxVcsqLFhki1MN4uWLoeKnCl5gIxpb3dwgK1v5MLLTaSwSsGWsodbJn5/GMaHhOUf6Wk7T3hJIei+Qm+VWQ/V2fv0VbEjl4ijKI+Fgh7JslaLDvI5CP9PONBEV6I/9iVzkGD1OGSOAHYNcT5g=");
string postDataStr = @"{""pageNo"":1,""pageSize"":10,""sort"":""department"",""department"":""2b7ac3ed-6cad-4307-93a4-1b111c5e182e000"",""dynamicFilter"":1}";
byte[] postdatabytes = Encoding.UTF8.GetBytes(postDataStr);
Stream writer;
writer = httpWebRequest.GetRequestStream();
writer.Write(postdatabytes, 0, postdatabytes.Length);
writer.Flush();
writer.Close();
httpWebRespones = (HttpWebResponse)httpWebRequest.GetResponse();
using (Stream stream = httpWebRespones.GetResponseStream())
{
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
strHtml = reader.ReadToEnd();
}
}
麻烦看下是否头信息不对,我用php试过是可以访问的
------解决思路----------------------
http头应该没问题,关键的是你post的参数是否正确,这个你要跟后台一起调试一下