我正在尝试使用海康威视 XML API 从我的海康威视相机配置中提取计数数据。我可以通过邮递员使用任何记录在案的服务来检索相机数据:
我的问题是试图让这些数据在 php 网页上打印出来。这是我的php代码:
<?php
$url = "https://169.254.119.130/ISAPI/System/Video/inputs/channels/1/counting/search";
$xml = '<?xml version="1.0" encoding="utf-16"?>
<countingStatisticsDescription xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.com TrackingRequestKnown.xsd">
<reportType>daily</reportType>
<timeSpanList>
<timeSpan>
<startTime>2021-11-28T00:00:00</startTime>
<endTime>2021-11-28T23:59:59</endTime>
</timeSpan>
</timeSpanList>
</countingStatisticsDescription>';
$creds='admin:camgene1!';
$headers = array(
"Content-type: application/xml",
"Content-length: " . strlen($xml),
"Accept: */*",
"Connection: keep-alive",
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);
curl_setopt($ch,CURLOPT_USERPWD,$creds);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$data = curl_exec($ch);
echo $data;
if(curl_errno($ch))
print curl_error($ch);
else
curl_close($ch);
?>
我的网页显示此消息:连接到 169.254.119.130:443 失败;拒绝连接
如果您可以建议我的代码中可能存在的任何明显错误,请告诉我!我的目标是保存所有 enterCount 和 LeaveCounts,以便有一个实时计数器来记录相机找到了多少人。