Skip to content
Advertisement

Parsing Request, PHP/Laravel

This API is used by an access control device to report personnel pass-through records, After me (A third-party platform) called the API to a face recognition terminal or face recognition access control terminal.

Calling direction:

A face recognition terminal or face recognition access control terminal calls the API to a third-party platform.

Request description:

Request method: POST Request URL: /LAPI/V1.0/System/Event/Notification/PersonVerification Content-Type: text/plain

Request example:

JavaScript

I am using Laravel, I got [] when tried $request->all(), below when I dump( $request->getContent() ); dump

Seems like I need to remove "" from beginning and end of request in order to json_decode(), but no matter what string function I used – preg_replace, substring, etc – nothing changed, when I tried $content[0] I got { and NOT ", $content[-1] I got n, $content[-2] I got }

Can anybody point out where I erred ?

Advertisement

Answer

Looks like this is the Content-Type header problem. But it should be a proper solution:

JavaScript

See this Repl for real implementation: Json Parse

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement