我目前正在尝试使用他们当前的API v3上传到imgur,但我不断收到错误
错误:javax.net.ssl.SSLException:证书中的主机名不匹配:api.imgur.com!= imgur.com或imgur.com
错误是非常自我解释的,所以我想我会尝试使用http而不是我得到错误代码400与imgur.我不确定这是否意味着我尝试上传是错误的还是Imgur不喜欢SSL连接.
下面是我连接到Imgur的代码模块:
public String Imgur (String imageDir, String clientID) {
//create needed strings
String address = "https://api.imgur.com/3/image";
//Create HTTPClient and post
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(address);
//create base64 image
BufferedImage image = null;
File file = new File(imageDir);
try {
//read image
image = ImageIO.read(file);
ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
ImageIO.write(image, "png", byteArray);
byte[] byteImage = byteArray.toByteArray();
String dataImage = new Base64().encodeAsString(byteImage);
//add header
post.addHeader("Authorization", "Client-ID" + clientID);
//add image
List<NameValuePair> …Run Code Online (Sandbox Code Playgroud)