Imgur API版本3 JavaScript上传示例 [英] Imgur API Version 3 JavaScript upload example

查看:110
本文介绍了Imgur API版本3 JavaScript上传示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网上找到的所有示例都是Imgur API的较早版本或非JS代码,它们均使用更新的API中不存在的API密钥.相反,您会得到一个client_idsecret.任何人都有示例代码,其中显示了如何使用其API版本3通过JavaScript(或jQuery)将图像上传到Imgur?

All the examples I find online are of earlier versions of the Imgur API or non JS code all of which uses an API key which doesn't exist in the newer API. Instead you get a client_id and secret. Anyone have example code that shows how an image can be uploaded to Imgur through JavaScript (or jQuery) using version 3 of their API?

推荐答案

$.ajax({ 
    url: 'https://api.imgur.com/3/image',
    headers: {
        'Authorization': 'Client-ID YOUR_CLIENT_ID'
    },
    type: 'POST',
    data: {
        'image': 'helloworld.jpg'
    },
    success: function() { console.log('cool'); }
});

这篇关于Imgur API版本3 JavaScript上传示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆