You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nodebb/src/imgur.js

35 lines
582 B
JavaScript

var request = require('request');
(function (imgur) {
"use strict";
var clientID = '';
imgur.upload = function (image, type, callback) {
var options = {
url: 'https://api.imgur.com/3/upload.json',
headers: {
'Authorization': 'Client-ID ' + clientID
}
};
var post = request.post(options, function (err, req, body) {
try {
callback(err, JSON.parse(body));
} catch (e) {
callback(err, body);
}
});
var upload = post.form({
type: type,
image: image
});
};
imgur.setClientID = function (id) {
clientID = id;
};
}(exports));