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:
{
"Reference": "204.2.1.20:5118/LAPI/V1.0/System/Event/Subscription/0",
"Seq": 5,
"DeviceCode": "210235C3R13202000093",
"Timestamp": 1564735558,
"NotificationType": 1,
"FaceInfoNum": 1,
"FaceInfoList": [
{
"ID": 5,
"Timestamp": 1564707615,
"CapSrc": 1,
"FeatureNum": 0,
"FeatureList": [
{
"FeatureVersion": "",
"Feature": ""
},
{
"FeatureVersion": "",
"Feature": ""
}
],
“Temperature”: 36.5,
“MaskFlag”: 1,
"PanoImage": {
"Name": "1564707615_1_86.jpg",
"Size": 101780,
"Data": "…"
},
"FaceImage": {
"Name": "1564707615_2_86.jpg",
"Size": 35528,
"Data": "…"
},
"FaceArea": {
"LeftTopX": 4981,
"LeftTopY": 3744,
"RightBottomX": 8250,
"RightBottomY": 5583
}
}
],
"CardInfoNum": 0,
"CardInfoList": [ ],
"GateInfoNum": 0,
"GateInfoList": [ ],
"LibMatInfoNum": 1,
"LibMatInfoList": [
{
"ID": 5,
"LibID": 3,
"LibType": 4,
"MatchStatus": 2,
"MatchPersonID": 0,
"MatchFaceID": 0,
"MatchPersonInfo": {
"PersonName": "",
"Gender": 0,
"CardID": "",
"IdentityNo": ""
}
}
]
}
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:
$find = ['/"""/', '/\n/', '/“/', '/”/'];
$replace = ['', '', '"', '"'];
$output = preg_replace($find, $replace, $your_input);
// now the $output is ready to be decoded
$decoded = json_decode($output);
$v = var_dump($decoded);
See this Repl for real implementation: Json Parse