接口简介
AI昆玉口检测接口主要通过拍摄手、足、口腔图片进行鉴别,返回患昆玉口病的概率信息。
接口地址
昆玉分辩访问地址:https://www.wuhanshanhaiguan.com/admin/api/hand_foot_analysis
口腔鉴别访问地址:https://www.wuhanshanhaiguan.com/admin/api/mouth_analysis
请求方式:POST
请求格式:application/x-www-form-urlencode
* 所有的请求和反应数据编码为utf-8格局,URL里的所有参数名和参数值请做URL编码
请求参数
| 字段 | 类型 | 是否必传 | 说明 |
|---|---|---|---|
| appid | String | 是 | 开放平台创建的appid |
| imgpath | String | 是 | 传入进行识别的网络图片地址 |
| timestamp | String | 是 | 请求端口的时间,时间格式yyyyMMddHHmmss |
| version | String | 是 | api版本,默认为1.0 |
| sign | String | 是 | 签名。把timestamp用MD5进行加密加上appid对应的key,然后再次用MD5进行加密生成签名,所有的MD5加密为大写。 |
响应参数
| 字段 | 类型 | 说明 |
|---|---|---|
| msg | String | 响应信息,成功为ok,错误为对应的错误信息 |
| code | Int | 反映码,200-胜利 201-他国可用次数 400-参数缺失或不对 500-异常 |
| data | json | 识别结果数据 |
返回结果示例:
{
"msg":"成功",
"code":200,
"data":{
"code":"88",
"handHongban":"no_0.999967575",
"handPaozhen":"no_0.99905947"
}
}
java调用代码示例
import com.alibaba.fastjson.JSON;
import com.util.HttpClient;
import java.io.IOException;
import java.security.MessageDigest;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
public class DemoObj {
public static String MD5(String data) throws Exception {
System.out.println(data);
MessageDigest md = MessageDigest.getInstance("MD5");
byte[] array = md.digest(data.getBytes("UTF-8"));
StringBuilder sb = new StringBuilder();
for (byte item : array) {
sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
}
System.out.println(sb.toString().toUpperCase());
return sb.toString().toUpperCase();
}
public static void main(String[] args) {
DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
String timestamp=df.format(new Date());
Map body = new HashMap<>();
body.put("appid", "你的APPID");
System.out.println(timestamp);
body.put("timestamp", timestamp);
body.put("version", "1.0");
body.put("imgpath", "舌头图片地址");
try {
body.put「"sign", MD5「MD5「timestamp」+"你的APPID对应的key"」」;
} catch (Exception e) {
e.printStackTrace();
}
try {
String s = new HttpClient().doPostMap("https://www.wuhanshanhaiguan.com/admin/api/hand_foot_analysis", body);
System.out.println(s);
Map maps = (Map) JSON.parse(s);
for (Object map : maps.entrySet()){
System.out.println(((Map.Entry)map).getKey()+" " + ((Map.Entry)map).getValue());
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
python调用代码示例
import hashlib
# 导入time模块
import time
import requests
import json
def Md5(res):
print(res)
md = hashlib.md5() # 构造一个md5
md.update(res.encode(encoding='utf-8'))
# 加密
print(md.hexdigest().upper())
return md.hexdigest().upper()
def testapi():
tures={}
restime=time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
# restime="20190829114035"
#传入参数
tures['timestamp']=restime
tures['appid']="你的APPID"
tures['version']='1.0'
tures['imgpath']='https://wxr-tongue.oss-cn-beijing.aliyuncs.com/images/tongue/IMG_20200913_134618.jpg',
tures['sign']=Md5「Md5「restime」+"你的APPID对应的key"」
url = "http://api.wuhanshanhaiguan.com/api/hand_foot_analysis"
response = requests.post(url, params=tures)
# print(response.text)
print(type(response.text))
load=json.loads(response.text)
print(load)
C#调用代码示例
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
namespace APITest
{
class Program
{
static void Main(string[] args)
{
Dictionary myDictionary = new Dictionary();
DateTime dt = DateTime.Now;
string ds = dt.ToString("yyyyMMddHHmmss");
myDictionary.Add("timestamp",ds);
myDictionary.Add「"appid", "你的APPID"」;
myDictionary.Add("version","1.0");
myDictionary.Add「"imgpath", "待测图片的云服务地址"」;
myDictionary.Add「"sign",GetMD5「GetMD5「ds」+ "你的APPID对应的key"」」;
string finalresult = Post("https://www.wuhanshanhaiguan.com/admin/api/hand_foot_analysis",myDictionary);
Object jo = JsonConvert.DeserializeObject「finalresult」; //此处结果为结尾的挪用结果
Console.WriteLine(jo);
Console.ReadKey();
}
//构造MD5
public static string GetMD5(string sDataIn)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] bytValue, bytHash;
bytValue = System.Text.Encoding.UTF8.GetBytes(sDataIn);
bytHash = md5.ComputeHash(bytValue);
md5.Clear();
string sTemp = "";
for (int i = 0; i
/// 指定Post地址使用Get 方式获取全部字符串
///
/// 请求后台地址
///
public static string Post(string url, Dictionary dic)
{
string result = "";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
#region 添加Post 参数
StringBuilder builder = new StringBuilder();
int i = 0;
foreach (var item in dic)
{
if (i > 0)
builder.Append("&");
builder.AppendFormat("{0}={1}", item.Key, item.Value);
i++;
}
byte[] data = Encoding.UTF8.GetBytes(builder.ToString());
req.ContentLength = data.Length;
using (Stream reqStream = req.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
reqStream.Close();
}
#endregion
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();
//获取响应内容
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
result = reader.ReadToEnd();
}
return result;
}
}
}
javascript调用代码示例
$.ajax({
type: "POST",
url: "https://www.wuhanshanhaiguan.com/admin/api/hand_foot_analysis",
data: {
timestamp:restime,
#restime时间格式为YYmmddHHMMSS
appid='你的APPID',
version='1.0',
imgpath='https://wxr-tongue.oss-cn-beijing.aliyuncs.com/images/tongue/IMG_20200913_134618.jpg',
sign=Md5「Md5「restime」+'你的APPID对应的key'」
},
success: function(msg) {
console.log('返回的数据:'+msg);
}
});