該接口用于門禁設備上報人員通行記錄,經我(第三方平臺)調用該接口給人臉識別終端或人臉識別門禁終端。呼叫方向:人臉識別終端或人臉識別門禁終端調用第三方平臺的API。請求描述:請求方法:POST 請求 URL:/LAPI/V1.0/System/Event/Notification/PersonVerification 內容類型:text/plain請求示例:{ "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 } } ], 我正在使用 Laravel,當我嘗試 $request->all() 時,我得到了 [],當我dump( $request->getContent() ); 轉儲時,我得到了下面的結果似乎我需要""從請求的開頭和結尾刪除才能進行 json_decode(),但無論我使用什么字符串函數 - preg_replace、substring 等 - 都沒有改變,當我嘗試 $content[0] 時,我得到了,但{不是", $content[-1] 我得到了\n,$content[-2] 我得到了}有人能指出我錯在哪里嗎?
1 回答

冉冉說
TA貢獻1877條經驗 獲得超1個贊
看起來這是Content-Type標題問題。但這應該是一個正確的解決方案:
? $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);?
- 1 回答
- 0 關注
- 143 瀏覽
添加回答
舉報
0/150
提交
取消