Imgur API Version 3 JavaScript upload example

不想你离开。 提交于 2019-12-20 08:39:23

问题


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?


回答1:


$.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'); }
});


来源:https://stackoverflow.com/questions/18088493/imgur-api-version-3-javascript-upload-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!