codeminders / imageshackapi

Automatically exported from code.google.com/p/imageshackapi
0 stars 0 forks source link

Api imageshack with Java #48

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,
Here a simple code to access REST api from imageshack, but I have always the 
same response:

{"success":true,"process_time":57,"result":{"max_filesize":25600000,"space_limit
":52428800,"space_used":1,"space_left":5242880,"passed":0,"failed":0,"total":0,"
images":[]}}

Here my code:
    WebResource resourceUpload =      client.resource("http://api.imageshack.us/v1/images");
    ObjectMapper mapper = new ObjectMapper();

    //LOGIN
    try {
      LoginDto loginDto = loginToImageshack();

      // UPLOAD
      String response = resourceUpload
      .queryParam("key", "****")
      .queryParam("url", "http://url_to_image")
      .queryParam("auth_token", loginDto.getResult().getAuth_token())
      .queryParam("format", "json")
      .accept(MediaType.APPLICATION_JSON)
      .header("Content-Type", "multipart/form-data")
      .post(String.class);

      System.out.println(response);

do you have an idea ?

Thanks for your response

Original issue reported on code.google.com by cle.ba...@gmail.com on 24 Feb 2014 at 8:29