Pergunta

I am using CamFind API for image recognition in my app. I am following CamFind Tutorial but stuck at how to get response from that API after posting data? How you got my question.

Foi útil?

Solução

try this code

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();
    }

now the body string contain the json response String with a Token variable inside it
and to get the recognition name do the same again, but remove the fields and add the Token value after the url so it will look like this: https://camfind.p.mashape.com/image_requests/(Token Vlaue)

now the body string will contain the name value

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top