string token = "b4de50360------cddddcopkjytrks";
//注册后生成的token (登录、注册的网址/user)
string host = "http://api.xinhuokj.com:40072/ocr" ;
Encoding encoding = Encoding.Default;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(host);
request.Method = "post";
request.KeepAlive = true;
// 图片的base64编码
string base64 = fileToBase64("demo.jpg");
//待测试的图片
String str = "{\"type\":\"11\", \"image\": \"" + base64 + "\", \"token\":\"" + token + "\" } ";
byte[] buffer = encoding.GetBytes(str);
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.Default);
string result = reader.ReadToEnd();
Console.WriteLine("OCR 通用识别:");
Console.WriteLine(result);