DEV Community

CHENG QIAN
CHENG QIAN

Posted on

The problem where the TP5 IoT project has been unable to get the request parameters

During an IoT project, when using ThinkPHP 5.0, the conventional framework methods failed to retrieve the parameters sent by the device's request—they always returned empty.

Eventually, the issue was resolved by using native PHP to obtain the request body. That is, parameters were fetched using PHP's native methods, resulting in a string, which was then converted into an object for further use.

$raw = file_get_contents('php://input');
$data = json_decode($raw, true);
Enter fullscreen mode Exit fullscreen mode

P.S. If you're looking for handy free utilities to assist with web development—like Base64 encoding, QR code generation, favicon creation, or text formatting—feel free to explore https://mantools.top/. It’s a lightweight, no-signup toolkit built for developers and creators. Hope it saves you a few minutes today!

Top comments (0)