如何上传图片到imgur相册?

How to upload image to imgur album?

我想使用 javascript 将图片上传到自己的相册。

这段代码可以上传图片到imgur,但是我不知道怎么上传到我的相册。

http://jsfiddle.net/FGxGg/57/

$.ajax({
url: "https://api.imgur.com/3/upload",
type: "POST",
datatype: "json",
data: {image: imgUrl},
success: showMe,
error: showMe,
beforeSend: function (xhr) {
    xhr.setRequestHeader("Authorization", "Client-ID " + clientId);
}});

或者对自己相册的图像托管有什么建议吗?

Imgur 有 detailed API documentation on all their endpoints, including Image Upload.

根据文档,您可以提供 album 参数以及要上传到的相册的 id。因此,更改您的数据以包含它:

var clientId = ""; // Your client Id
var imgUrl = "http://i.imgur.com/l5OqYoZ.jpg";
var albumId = 'ABC123'; // Your owned album id

$.ajax({
  url: "https://api.imgur.com/3/upload",
  type: "POST",
  datatype: "json",
  data: {image: imgUrl, album: albumId},
  success: showMe,
  error: showMe,
  beforeSend: function (xhr) {
    xhr.setRequestHeader("Authorization", "Client-ID " + clientId);
}});