Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

220
Vistas
Why my Imgur API in Javascript doesn't work?

I need to upload my image in imgur with imgur's API, and i do that in Javascript but i have all time a response like "429 - Too many request" or "403 - Imgur is temporarily over capacity. Please try again later". And I also do a API test in PHP but with this i have no problem

I need help to understand why my call API in JS doesn't work

(the file in my function JS come to HTML tag input file multiple)

My JS code

function FolderAddPictureUploadImgur(file) {
    var imgur_client_id = "xxxx";
    
    const formData = new FormData();
    formData.append('image', file);
    
    fetch('https://api.imgur.com/3/image', {
        method: 'POST',
        headers: {
        Authorization: 'Client-ID '+ imgur_client_id,
        },
        body: formData
    }).then(response => {
        console.log(response);
        if (response.ok) {
        alert('Image uploaded to album');       
        }
    }).catch(error => {
        console.error(error);
        //alert('Upload failed: ' + error);
    });
}

My code PHP

<?php
$imgur_client_id = 'xxx';

$file = file_get_contents("test_image.png");

$url = 'https://api.imgur.com/3/image.json';
$headers = array("Authorization: Client-ID $imgur_client_id");
$pvars  = array('image' => base64_encode($file));

$curl = curl_init();
curl_setopt_array($curl, array(
   CURLOPT_URL=> $url,
   CURLOPT_TIMEOUT => 30,
   CURLOPT_POST => 1,
   CURLOPT_RETURNTRANSFER => 1,
   CURLOPT_HTTPHEADER => $headers,
   CURLOPT_POSTFIELDS => $pvars
));

$json_returned = curl_exec($curl); // blank response
echo($json_returned);

$json_returned = json_decode($json_returned, true);

curl_close ($curl); 

?>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda