1
我正在使用Azure OCR服務,現在我想要將數據保存到數組中。 不幸的是我總是收到此錯誤信息:PHP Azure OCR - 在數組中轉換JSON
PHP Warning: json_decode() expects parameter 1 to be string, object given in XXX on line 43
我的輸出IST:
{"language":"en","textAngle":-2.5000000000000346,"orientation":"Up","regions":[{"boundingBox":"896,2104,1528,688","lines":[{"boundingBox":"896,2104,1528,688","words":[{"boundingBox":"896,2104,1528,688","text":"DFG"}]}]}]}
我的代碼是:
$request->setHeader($headers);
$parameters = array(
// Request parameters
'language' => 'unk',
'detectOrientation ' => 'true',
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_POST);
$body = array('url' => 'https://i.imgur.com/2sUbQC8.jpg');
$request->setBody(json_encode($body));
// Request body
try
{
$response = $request->send();
echo $response->getBody();
$json = json_decode($response, true);
}
catch (HttpException $ex)
{
echo "Fehler :(";
echo $ex;
}
?>
嘗試'$ JSON = json_decode($響應 - > getBody(),真)' – Kisaragi