从海康威视摄像机获取实时lpr结果

时间:2019-04-05 08:29:41

标签: postman

我想从海康威视LPR摄像机获取实时LPR结果。我有来自海康威视ISAPI文档的链接:/ ISAPI / Traffic / channels / 1 / vehicleDetect / plates

我收到以下错误:

<?xml version="1.0" encoding="UTF-8"?>
<ResponseStatus version="2.0" xmlns="http://www.std-cgi.com/ver20/XMLSchema">
    <requestURL>/ISAPI/Traffic/channels/1/vehicleDetect/plates</requestURL>
    <statusCode>6</statusCode>
    <statusString>Invalid XML Content</statusString>
    <subStatusCode>badXmlContent</subStatusCode>
</ResponseStatus>

此链接不起作用,而/ ISAPI / Traffic / channels / 1 / vehicleDetect /起作用。请帮我解决这个问题。

2 个答案:

答案 0 :(得分:1)

无效的XML内容

HTTP内容“ 0” <抓取最后20个板块

HTTP方法是“ POST”!不是GET文档是错误的,永远不要将任何数据发送到Servur;),这就是为什么在输入时获得无效的xml格式的原因

答案 1 :(得分:0)

作品:

$username = 'xxxxx';
$password = 'yyyyy';

$url = "https://xxx.xxx.xxx.xxx/ISAPI/Traffic/channels/1/vehicleDetect/plates";



$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch,CURLOPT_TIMEOUT, 30);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "<AfterTime version=\"2.0\"><picTime>2020-06-20T00:00:00Z</picTime></AfterTime>"); 
$first_response = curl_exec($ch);
$info = curl_getinfo($ch);

preg_match('/WWW-Authenticate: Digest (.*)/', $first_response, $matches);

if(!empty($matches))
{
  $auth_header = $matches[1];
  $auth_header_array = explode(',', $auth_header);
  $parsed = array();

  foreach ($auth_header_array as $pair)
  {
    $vals = explode('=', $pair);
    $parsed[trim($vals[0])] = trim($vals[1], '" ');
  }

  $response_realm     = (isset($parsed['realm'])) ? $parsed['realm'] : "";
  $response_nonce     = (isset($parsed['nonce'])) ? $parsed['nonce'] : "";
  $response_opaque    = (isset($parsed['opaque'])) ? $parsed['opaque'] : "";

  $authenticate1 = md5($username.":".$response_realm.":".$password);
  $authenticate2 = md5("POST:".$url);

  $authenticate_response = md5($authenticate1.":".$response_nonce.":".$authenticate2);

  $request = sprintf('Authorization: Digest username="%s", realm="%s", nonce="%s", opaque="%s", uri="%s", response="%s"',
  $username, $response_realm, $response_nonce, $response_opaque, $url, $authenticate_response);

  $request_header = array($request);
  $request_header[] = 'Content-Type:application/json';

  $ch = curl_init();
  curl_setopt($ch,CURLOPT_URL, $url);
  curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch,CURLOPT_SSL_VERIFYHOST, false);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch,CURLOPT_FOLLOWLOCATION, false);
  curl_setopt($ch,CURLOPT_TIMEOUT, 30);
  curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 30);
  curl_setopt($ch,CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_POSTFIELDS, "<AfterTime version=\"2.0\"><picTime>2020-06-20T00:00:00Z</picTime></AfterTime>"); 
  curl_setopt($ch, CURLOPT_HTTPHEADER, $request_header);

  $result['response']= curl_exec($ch);
  
 print_r($result['response']);

}