HuyPV
Thursday, November 8, 2018
You log requests from the merchants and found this strange:
$_GET is empty
$_POST is empty
but $request->get('email') has value
So where is "email" value?
Laravel alredy process JSON data (raw request) and return the values
You should log file_get_contents('php://input') and see
Now you can do sample test:
curl -H "Content-Type: application/json" -d "{""mobile"":123}" https://your-api.com/sample/echo
public function postEcho(Request $request) {
echo $request->get('mobile');
echo '<br />';
echo(file_get_contents('php://input'));
}
Title:
Laravel request get from JSON data
Description:
$_GET, $_POST is empty but $request->get still return value. The reason is raw post content
...
Rating:
4