S
S
smilelan2020-05-21 13:02:42
Laravel
smilelan, 2020-05-21 13:02:42

How to send a Post request to another site with parameters?

Good day to all! How can I pass POST parameters with a request from a controller?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
FanatPHP, 2020-05-21
@FanatPHP

Laravel POST request to another site

I
Igor Vorotnev, 2020-05-21
@HeadOnFire

Laravel 7:

Http::post('https://example.com/endpoint', [
    'param' => 'value',
]);

I
Ilya, 2020-05-21
@rpsv

CUlm'om request to make:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
  'param1' => 'value2',
]));
curl_exec($ch);
curl_close($ch);

https://www.php.net/manual/en/function.curl-exec.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question