4

I signed up for the Imgur API and registered a test app and recoived a Client ID and a Client Secret.

I then tried to use this code:

try {
    var image = canvas.toDataURL('image/jpeg', 0.9).split(',')[1];
} catch(e) {
    var image = canvas.toDataURL().split(',')[1];
}

// upload to imgur using jquery/CORS
// https://developer.mozilla.org/En/HTTP_access_control
$.ajax({
    url: 'http://api.imgur.com/2/upload.json',
    type: 'POST',
    data: {
        type: 'base64',
        // get your key here, quick and fast http://imgur.com/register/api_anon
        key: '123',
        name: 'neon.jpg',
        title: 'test title',
        caption: 'test caption',
        image: image
    },
    dataType: 'json'
}).success(function(data) {
    window.location.href = data['upload']['links']['imgur_page'];
}).error(function() {
    alert('Could not reach api.imgur.com. Sorry :(');
    window.close();
});

Which I found here to upload an image to Imgur. I replaced "123" in the example above with my client id but the ajax response comes back with the error "Invalid API key". I didn't receive an API key but a client ID and client secret. I tried a variation of the 2 but still no luck. How to get this past API key issue? Also is the code above outdated because I think there is a version 3 of the API but that seems to only work with https and I don't have a SSL on my site.

  • 1
    If anyone else has this issue the answer can be found here: http://stackoverflow.com/questions/18088493/imgur-api-version-3-javascript-upload-example –  Aug 10 '13 at 14:31

0 Answers0