我正在处理本地服务器 192.168.1.1 的任务。我想获取页面的数据
192.168.1.1/userRpm/SystemStatisticRpm.htm?Num_per_page=100
我想显示这个文件返回的 HTML 代码。
当我在 curl -u admin:admin PageURL 之类的终端上运行 curl 命令时(它返回页面代码)
但是当我使用 PHP curl 时,它会将我重定向到 192.168.1.1
有谁能够帮助我 ?
我的代码是:
<?php
$json_url="http://192.168.1.1/userRpm/SystemStatisticRpm.htm?Num_per_page=100";
$username="admin";
$password="admin";
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $json_url);
curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type:application/json'));
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$result=curl_exec($ch);
curl_close ($ch);