Http://apistore.baidu.com/apiworks/servicedetail/146.html
protected void Button1_Click (object sender, EventArgs e) {Stream fstream = FileUpload1.PostedFile.Inpu TStream; byte[] img = new Byte[fstream. Length]; FStream. Read (IMG, 0, IMG. Length); FStream. Close (); String imgdata = Convert.tobase64string (IMG); String url = "HTTP://APIS.BAIDU.COM/APISTORE/IDLOCR/OCR"; string param = "Fromdevice=pc&clientip=10.10.10.0&detecttype=locaterecognize&languagetype=chn_eng &imagetype=1&image= "+imgdata; string result = Request (Url,param); Ss. Text = result; }///<summary>///Send HTTP request///</summary>///<param name= "url" > Requested url</param>///<param Name= "param" > requested parameter </param>///<returns> request result </returns>public static string request (string URL, string param) {string strurl = URL; System.Net.HttpWebRequest request; Request = (System.Net.HttpWebRequest) webrequest.create (strURL); Request. Method = "POST"; Add the header request. Headers.add ("Apikey", "e0bbb1655505bcb36a6581a5b632207a"); Request. ContentType = "application/x-www-form-urlencoded"; 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 + "<br>"; } return strvalue;}
Use Baidu interface to identify identity cards