将图像匿名上传到Imgur

所以我一直试图使用imgur api来匿名上传图片,而我似乎无法使其工作。 我觉得我正在做我需要做的事情,但是我被api关闭,出现以下错误:

{ “错误”:{ “消息”: “否API密钥被发送,并没有用户被认证”, “请求”: “// 2 / upload.json”, “方法”: “后”, “格式”: “json”,“parameters”:“image = /storage/emulated/0/DCIM/Camera/IMG_20150404_191703.jpg”}}

我创建了一个选择anontmous使用选项(https://api.imgur.com/oauth2/addclient)的应用程序,我使用我的客户端ID,但不知何故,它仍然不够。 如果有人认为这是什么问题,将不胜感激!

       try {
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(IMGUR_POST_URI);

        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        nvps.add(new BasicNameValuePair("image", params[0]));
        httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8"));

        httpPost.addHeader("Authorization", "Client-ID " + IMGUR_API_KEY);


        HttpResponse response = httpClient.execute(httpPost);
        HttpEntity entity = response.getEntity();

        if (entity != null) {
            BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
            StringBuilder content = new StringBuilder();
            String line;
            while (null != (line = br.readLine())) {
                content.append(line);
            }
            System.out.println(content);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
链接地址: http://www.djcxy.com/p/81441.html

上一篇: Upload image anonymously to Imgur

下一篇: Which parts of the ImgurV3 API can be used anonymously?