我正在尝试登录相机并在某个网页上获得json响应。当我在一些相机上做的很好。有些相机的cookie会以非常旧的日期返回。任何想法为什么会发生这种情况。
// login in requset
_request = (HttpWebRequest)WebRequest.Create(_uri);
_request.KeepAlive = true;
_request.UserAgent = "curl/7.54.1\r\n";
_request.ContentType = "application/json";
_request.ProtocolVersion = HttpVersion.Version10;
_request.Method = "POST";
using (var sw = new StreamWriter(_request.GetRequestStream()))
{
string json = jsonCommand;
sw.Write(json);
sw.Flush();
sw.Close();
}
// get cookies
request.CookieContainer = cookie;
request.EndGetRequestStream(asynchronousResult);
var cookies = response.Cookies;
foreach (Cookie cook in cookies)
{
_cookie.Add(cook);
}
// send a request for a json response
_request = (HttpWebRequest)WebRequest.Create(_uri);
_request.KeepAlive = true;
_request.UserAgent = "curl/7.54.1\r\n";
_request.ProtocolVersion = HttpVersion.Version10;
答案 0 :(得分:0)
成功:
相机是统一的uvc g2。我设置了日期和时间,并且能够使用上面的代码来获取json响应。唯一的问题是我必须通过NVR连接以管理摄像机,才能有时间进行同步。
成功:
一旦我管理和取消管理相机,只要我不摆弄日期时间的设置,它就会同步。