I have a dvr. Some cameras are attached to it. The dvr can be accessed by a web browser from Internet. The dvr is protected by username and password. How can I connect to the webserver without typing everytime login and password? There is a way to do it in 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:
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. But how to go on? I to enter the web site of the weserver?
Try this:
$base_url = "http://". $username. ":". $password. "@myip/cgi-bin/slogin/login.py";
... in lieu of the curl_setopt
calls. This should hopefully stay present as the uri is changed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.