2013-08-19, 07:02 PM
2013-08-19, 07:02 PM
2013-08-21, 04:18 PM
I think the old auth method has changed and the new api endpoint is different. Wish I knew JS.
2013-08-24, 09:46 PM
(2013-08-21, 04:18 PM)Bitz Wrote: [ -> ]I think the old auth method has changed and the new api endpoint is different. Wish I knew JS.
for V3 API:
Change imgur.php to below:
<html>
<head>
<title>Upload to Imgur</title>
</head>
</html>
<div><img src="images/imgur.png" border="0" /></div>
<br /><br />
<button onclick="document.querySelector('input').click()">Select file...</button>
<input style="visibility: collapse; width: 0px;" type="file" onchange="upload(this.files[0])">
<script>
window.ondragover = function(e) {e.preventDefault()}
window.ondrop = function(e) {e.preventDefault(); upload(e.dataTransfer.files[0]); }
function upload(file) {
/* Is the file an image? */
if (!file || !file.type.match(/image.*/)) return;
/* It is! */
document.body.className = "uploading";
/* Lets build a FormData object*/
var fd = new FormData(); // I wrote about it: https://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/
fd.append("image", file); // Append the file
var xhr = new XMLHttpRequest(); // Create the XHR (Cross-Domain XHR FTW!!!) Thank you sooooo much imgur.com
xhr.open("POST", "https://api.imgur.com/3/image.json"); // Boooom!
xhr.onload = function() {
var code = '[img]' + JSON.parse(xhr.responseText).data.link + '[/img]';
var editor = eval('opener.' + 'clickableEditor');
editor.performInsert(code);
javascript:window.close()
}
// Ok, I don't handle the errors. An exercice for the reader.
xhr.setRequestHeader('Authorization', 'Client-ID <yourkey>');
/* And now, we send the formdata */
xhr.send(fd);
}
</script>
<!-- Bla bla bla stuff ... -->
<style>
body {text-align: center; background-color: #181817; overflow-x:hidden; overflow-y:auto;}
div { background-color: rgb(43, 43, 43); border-bottom: 4px solid rgb(68, 68, 66); margin: -8px;}
p {display: none}
.uploading p {display: inline}
</style>
<br /><br />
<p><img src="images/loader.gif" border="0" /></p>
Based in http://stackoverflow.com/questions/16951...javascript
2013-10-29, 07:43 PM
martec, does the key go inside the <> in this part of the code?
xhr.setRequestHeader('Authorization', 'Client-ID <yourkey>');
2013-10-29, 08:00 PM
OK, I finally got it working.
Here's my revised code with out all of the HTML errors:
Here's my revised code with out all of the HTML errors:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<title>Upload to Imgur</title>
</head>
<body>
<div>
<img src="images/imgur.png" border="0" /></div>
<button onclick="document.querySelector('input').click()">Select file...</button>
<input style="visibility: collapse; width: 0px;" type="file" onchange="upload(this.files[0])">
<script>
window.ondragover = function(e) {e.preventDefault()}
window.ondrop = function(e) {e.preventDefault(); upload(e.dataTransfer.files[0]); }
function upload(file) {
/* Is the file an image? */
if (!file || !file.type.match(/image.*/)) return;
/* It is! */
document.body.className = "uploading";
/* Lets build a FormData object*/
var fd = new FormData(); // I wrote about it: https://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/
fd.append("image", file); // Append the file
var xhr = new XMLHttpRequest(); // Create the XHR (Cross-Domain XHR FTW!!!) Thank you sooooo much imgur.com
xhr.open("POST", "https://api.imgur.com/3/image.json"); // Boooom!
xhr.onload = function() {
var code = '[img]' + JSON.parse(xhr.responseText).data.link + '[/img]';
var editor = eval('opener.' + 'clickableEditor');
editor.performInsert(code);
javascript:window.close()
}
// Ok, I don't handle the errors. An exercice for the reader.
xhr.setRequestHeader('Authorization', 'Client-ID 1234567890');
/* And now, we send the formdata */
xhr.send(fd);
}
</script>
<span style="color:#fff;text-align:center;display:block;margin: 1em">Browse for your image, or drag and drop it into this window if you use FF or Chrome.</span>
<style>
body {text-align: center; background-color: #000; overflow-x:hidden; overflow-y:auto; color:#888}
div { background-color: rgb(43, 43, 43); border-bottom: 4px solid rgb(68, 68, 66); margin: -8px;}
p {display: none}
.uploading p {display: inline}
</style>
<p><img src="images/loader.gif" border="0" /></p>
</body>
</html>
2013-10-30, 01:43 AM
(2013-10-29, 07:43 PM)Shemo Wrote: [ -> ]martec, does the key go inside the <> in this part of the code?
xhr.setRequestHeader('Authorization', 'Client-ID <yourkey>');
in
<yourkey>
put Client ID key
result something this
xhr.setRequestHeader('Authorization', 'Client-ID 123456789');
123456789 = Client ID key
Client Secret it's not necessary...
2013-10-30, 08:13 PM
(2013-10-30, 01:43 AM)martec Wrote: [ -> ](2013-10-29, 07:43 PM)Shemo Wrote: [ -> ]martec, does the key go inside the <> in this part of the code?
xhr.setRequestHeader('Authorization', 'Client-ID <yourkey>');
in
<yourkey>
put Client ID key
result something this
xhr.setRequestHeader('Authorization', 'Client-ID 123456789');
123456789 = Client ID key
Client Secret it's not necessary...
after switching to the new imgur.php and trying to upload a photo, when it places the [img] information in a post, this is how mine keeping showing up:
[img]undefined[/img]
2013-10-30, 08:22 PM
Shemo,
That was my problem too, and I spent a lot of time figuring it out. Try my code in this post and let me know if that works. Remember to paste in your key.
http://community.mybb.com/thread-134658-...pid1045024
That was my problem too, and I spent a lot of time figuring it out. Try my code in this post and let me know if that works. Remember to paste in your key.
http://community.mybb.com/thread-134658-...pid1045024
(2013-10-30, 08:13 PM)Shemo Wrote: [ -> ](2013-10-30, 01:43 AM)martec Wrote: [ -> ](2013-10-29, 07:43 PM)Shemo Wrote: [ -> ]martec, does the key go inside the <> in this part of the code?
xhr.setRequestHeader('Authorization', 'Client-ID <yourkey>');
in
<yourkey>
put Client ID key
result something this
xhr.setRequestHeader('Authorization', 'Client-ID 123456789');
123456789 = Client ID key
Client Secret it's not necessary...
after switching to the new imgur.php and trying to upload a photo, when it places the [img] information in a post, this is how mine keeping showing up:
[img]undefined[/img]
2013-10-31, 04:53 PM
(2013-10-30, 08:22 PM)Monaco Wrote: [ -> ]Shemo,
That was my problem too, and I spent a lot of time figuring it out. Try my code in this post and let me know if that works. Remember to paste in your key.
http://community.mybb.com/thread-134658-...pid1045024
(2013-10-30, 08:13 PM)Shemo Wrote: [ -> ](2013-10-30, 01:43 AM)martec Wrote: [ -> ](2013-10-29, 07:43 PM)Shemo Wrote: [ -> ]martec, does the key go inside the <> in this part of the code?
xhr.setRequestHeader('Authorization', 'Client-ID <yourkey>');
in
<yourkey>
put Client ID key
result something this
xhr.setRequestHeader('Authorization', 'Client-ID 123456789');
123456789 = Client ID key
Client Secret it's not necessary...
after switching to the new imgur.php and trying to upload a photo, when it places the [img] information in a post, this is how mine keeping showing up:
[img]undefined[/img]
still shows undefined for me.
2014-01-02, 09:23 PM
Guys, it first showed as undefined to, after some googling I found the fix.
Seems like a typo issue.
Just copy paste this one;
I hope this helps!
Seems like a typo issue.
Just copy paste this one;
xhr.setRequestHeader('Authorization', 'Client-ID PUBLICKEYHERE);
I hope this helps!