string token = "b4de50360------cddddcopkjytrks";
//注冊后生成的token (登錄、注冊的網址http://www.qdtingmei.com/user)
string host = "http://api.xinhuokj.com:28901/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\":\"0\", \"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);