Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

482
Visualizações
How to send PHP input stream data using curl?

POST

On my local machine, I want to use cURL as an HTTP client like so:

curl -X POST -F 'email=derp@example.com' -F 'password=blink182' http://example.com

The above curl statement uses the HTTP POST method which can be retrieved in PHP like so:

echo $_POST['email'];       // derp@example.com
echo $_POST['password'];    // blink182

php://input

However, what I really wanted is the data from the PHP input stream php:://input and not from the POST method $_POST.

The PHP input stream can be retrieved in PHP like so:

$input = json_decode( file_get_contents( 'php://input' ) );
echo $input->email;     // derp@example.com
echo $input->password;  // blink182

Which brings me to my question, how to send PHP input stream data using curl?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

From the PHP website:

php://input is a read-only stream that allows you to read raw data from the request body. php://input is not available with enctype="multipart/form-data".

So if you specify the Content-Type as application/json using -H "Content-Type: application/json" you ought to get it in the input stream

complete example:

curl -X POST https://reqbin.com/echo/post/json
   -H 'Content-Type: application/json'
   -d '{"email":"derp@example.com","password":"blink182"}'
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda