简体   繁体   English

在 php 中访问受密码保护的远程 DVR

[英]Access remote DVR protected by password in php

I have a dvr.我有一个 dvr。 Some cameras are attached to it.一些相机连接到它。 The dvr can be accessed by a web browser from Internet.可以通过 web 浏览器从 Internet 访问 dvr。 The dvr is protected by username and password. dvr 受用户名和密码保护。 How can I connect to the webserver without typing everytime login and password?如何在不输入每次登录名和密码的情况下连接到网络服务器? There is a way to do it in php? php 有办法做到这一点吗? I used this script我用了这个脚本

<?
$username = "xxxx";
$password = "aaaa";

$base_url = "http://myip/cgi-bin/slogin/login.py";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $base_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
print_r($info);
curl_close($ch);
?>

When I connect, I get the details of print_r, but nothing else:当我连接时,我得到了 print_r 的详细信息,但没有其他信息:

Array ( [url] => http://xx.xx.xxx.xx/cgi-bin/slogin/login.py [content_type] => text/html;    charset=iso-8859-1 [http_code] => 200 [header_size] => 225 [request_size] => 121 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.823264 [namelookup_time] => 0.00104 [connect_time] => 0.120289 [pretransfer_time] => 0.120435 [size_upload] => 0 [size_download] => 1515 [speed_download] => 1840 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => -1 [starttransfer_time] => 0.690632 [redirect_time] => 0 [certinfo] => Array ( ) ) 

I saw that there is a 200OK, so I guess the connection was fine.我看到有一个200OK,所以我猜连接很好。 But how to go on?但是go怎么开呢? I to enter the web site of the weserver?我要进入weserver的web站点?

Try this:尝试这个:

$base_url = "http://". $username. ":". $password. "@myip/cgi-bin/slogin/login.py";

... in lieu of the curl_setopt calls. ...代替curl_setopt调用。 This should hopefully stay present as the uri is changed.随着 uri 的更改,这应该会一直存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM