javascript - Sideloading images to imgur without API key -
i've been trying use feature of imgur api allows send request http://api.imgur.com/2/upload
url in form data, , have image uploaded, can't work, returns nothing.
$.get("http://api.imgur.com/2/upload.json", { url: 'http://upload.wikimedia.org/wikipedia/commons/3/3e/phalaenopsis_jpeg.png' }, function(data) { return console.log(data); });
are there alternatives? or know how can above code work?
ah, in fact working!
the location of uploaded image being returned location
in response headers.
edit:
i found wasn't able access headers had come else. here's snippet upload using yql:
urltoimgur = (url, callback) -> upload_url = "http://api.imgur.com/2/upload?url=#{url}" $.ajax url: 'http://query.yahooapis.com/v1/public/yql' datatype: 'jsonp' data: q: "select none html url='#{upload_url}'" diagnostics: true success: (data) -> redirects = data.query.diagnostics.redirect image_url = redirects[redirects.length-1].content callback image_url
Comments
Post a Comment