Laravel:
PHP Code:
Route::post('/test', function (Request $request) {
return response()->json($request->all());
});
Simple PHP:
PHP Code:
<?php
$postData = json_encode($_POST);
$jsonData = file_get_contents('php://input');
echo $postData;
echo $jsonData;
file_put_contents('post.txt', $postData);
file_put_contents('json.txt', $jsonData);
?>
Both solutions receives nothing when requesting from game server.
@edit:
PHP Code:
Request.AppendFormParam("test", "%s", "foo");
Request.PostForm(OnTestRequest);
I've used PostForm instead of Post but i still don't know why Post + JSON doesn't work...
@edit-2:
I've saved some backend logs:
PostForm():
PHP Code:
[2021-06-08 14:39:05] local.DEBUG: Content-Type: "application\/x-www-form-urlencoded"
[2021-06-08 14:39:05] local.DEBUG: Accept: "application\/json"
[2021-06-08 14:39:05] local.DEBUG: Path: "api\/test2"
[2021-06-08 14:39:05] local.DEBUG: Method: "POST"
[2021-06-08 14:39:05] local.DEBUG: Data: {"test":"foo"}
[2021-06-08 14:39:05] local.DEBUG: $_POST: {"test":"foo"}
Post() + JSON
PHP Code:
[2021-06-08 14:41:40] local.DEBUG: Content-Type: "application\/json"
[2021-06-08 14:41:40] local.DEBUG: Accept: "application\/json"
[2021-06-08 14:41:40] local.DEBUG: Path: "api\/test2"
[2021-06-08 14:41:40] local.DEBUG: Method: "POST"
[2021-06-08 14:41:40] local.DEBUG: Data: []
[2021-06-08 14:41:40] local.DEBUG: $_POST: []
Post() + JSON (Content-Type: application/x-www-form-urlencoded)
PHP Code:
[2021-06-08 14:42:42] local.DEBUG: Content-Type: "application\/x-www-form-urlencoded"
[2021-06-08 14:42:42] local.DEBUG: Accept: "application\/json"
[2021-06-08 14:42:42] local.DEBUG: Path: "api\/test2"
[2021-06-08 14:42:42] local.DEBUG: Method: "POST"
[2021-06-08 14:42:42] local.DEBUG: Data: []
[2021-06-08 14:42:42] local.DEBUG: $_POST: []
It will be really nice to log what extension sends to backend (to be sure that isn't extension bug)...