简体   繁体   English

如何将图像上传到imgur相册?

[英]How to upload image to imgur album?

I would like to upload image to own album by using javascript. 我想使用javascript将图像上传到自己的相册。

This code can upload image to imgur, but I dont know how to upload it to my album. 此代码可以将图像上传到imgur,但是我不知道如何将其上传到我的相册。

http://jsfiddle.net/FGxGg/57/ 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);
}});

Or any suggestion for image hosting to own album? 或对将图片托管到自己的相册有任何建议?

Imgur has detailed API documentation on all their endpoints, including Image Upload . Imgur在所有端点上都有详细的API文档 ,包括Image Upload

According to the documentation, you can supply an album parameter with the id of the album you want to upload to. 根据文档,您可以提供一个album参数以及您要上传到的相册的id So, change your data to include it: 因此,更改您的数据以包括它:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM