1
我在我的应用程序中使用CamFind API进行图像识别。我正在关注CamFind Tutorial ,但坚持在发布数据后如何从API获取响应?你如何得到我的问题。如何获得CamFind API的结果?
我在我的应用程序中使用CamFind API进行图像识别。我正在关注CamFind Tutorial ,但坚持在发布数据后如何从API获取响应?你如何得到我的问题。如何获得CamFind API的结果?
试试这个代码
try {
HttpResponse<JsonNode> request = Unirest
.post("https://camfind.p.mashape.com/image_requests")
.header("X-Mashape-Authorization",
"A0MYOpCsdfasdgadfadafgdj7vsdfe")
.field("image_request[locale]", "en_US")
.field("image_request[image]",
new File("your Image path")).asJson();
String body = request.getBody().toString();
Log.v("body", body);
} catch (UnirestException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
现在身体字符串包含在它里面有一个令牌变量JSON响应字符串
并得到认可其名一样了,但除去fields
并添加Token
网址 后值,使之看起来就像这样: https://camfind.p.mashape.com/image_requests/(Token Vlaue)
现在身体字符串将包含name
值