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

655
Vistas
HTTP/1.1 426 Upgrade Required - file_get_contents (PHP) on Apache2 server (debian 9)

First post here, I'm running into an issue I didn't have when working on my local machine /w XAMPP.

I've push some basic PHP code on my VPS with a fresh Apache2 and PHP7 install, and one of the file is actually doing a file_get_contents to do a GET request on Trello's API:

$lists = json_decode(file_get_contents("https://api.trello.com/1/boards/<<HIDDEN>>/lists?key={$id}&token={$token}"), true);

The problem is that I'm receiving this HTTP response when doing so:

[Tue Aug 24 14:27:14.132294 2021] [:error] [pid 17956] [client <<HIDDEN>>] PHP Warning:  file_get_contents(https://api.trello.com/1/boards/<<HIDDEN>>/lists?key=<<HIDDEN>>&amp;token=<<HIDDEN>>): failed to open stream: HTTP request failed! HTTP/1.1 426 Upgrade Required\r\n in <HIDDEN>/trello.php on line 7, referer: <<HIDDEN>>

I've done some research and I saw that I kinda need to upgrade the call to another HTTP protocol but so far, I have no clues about the way to proceed...

Any advice, tip?

Thanks!

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Ok, so I still have no clues about how to fix that using file_get_contents, but I found a workaround that seems to work using curl.

If some people are also having the issue, I've replaced the initial request with that:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://api.trello.com/1/boards/<<HIDDEN>>/lists?key={$id}&token={$token}");
    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2);
    curl_setopt($ch, CURLOPT_HTTPGET, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $lists = json_decode(curl_exec($ch), true);
    curl_close($ch);

Looks like the curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2); is doing the job.

That's not answering the root question (how to do that with file_get_contents) but if it can help...

Thanks!

over 4 years ago · Santiago Trujillo Denunciar
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