Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Ev-genius's avatar

How to receive POST from other site

POST request comes from another site to the page /callback Need to receive it, save data and send status 200 back.

View is not needed Tried to do it in routes, for sample:

use Illuminate\Http\Request;

Route::get('/callback', function (Request $request) {

$request = request()->post();

Log::info($request);
return response('', 200); });

if we specify the $request = '123', then the log is written

[2020-09-09 04:25:12] local.INFO: 123

otherwise the log is empty

What am I doing wrong?

0 likes
7 replies
Ev-genius's avatar

Done.

in VerifyCsrfToken.php

protected $except = [ 'https://mysite.com/callback' ];

But nothing...

But if I go to the page myself, then an empty array is written in the logs. [2020-09-09 04:45:23] local.INFO: array ()

Am I sending the 200 response correctly? without this response, the other site does not transmit data

Sinnbeck's avatar

Well you should check the response you are getting on the other site. And I would suggest you use a relative url

protected $except = [ 'callback' ];
Ev-genius's avatar

set in VerifyCsrfToken.php

protected $except = [ 'callback' ];

Support on other site says it gets a 405 response

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Did you remember to change the route to expect a post request?

Route::post('/callback', function (Request $request) {

$request = request()->post();

Log::info($request);
return response('', 200); 
});
Ev-genius's avatar

It worked! OMG It worked! Thank you Sinnbeck very very much!

I already tried to change get to a post, but when I went to this address myself, it showed an error, and I didn't even think to check. Of course ... the page was waiting for the Post...

well... went to repeat the basics.

Thank you again, Sinnbeck!

Please or to participate in this conversation.