Heim >Backend-Entwicklung >PHP-Tutorial >CURL模拟POST传递参数问题
请大家帮我看一下,我使用CURL函数模拟页面间传递参数,但是测试后发现参数总是不能传递到指定的页面,请帮我分析一下,我的代码附上:
header("Content-Type: text/html; charset=utf-8");
include("basic-lanconf.php");
echo"--------------------basic-lan配置结果-------------------";
echo"-------------------------------------------------------";
echo"(1).basic-lan配置测试结果:";
$url="http://192.168.0.1/tomato.cgi";
$head=array();
$head[]="Authorization: Basic " . base64_encode($admin.":".$pass);
$curlPost="lan_ipaddr=$lan_ipaddr&lan_netmask=$lan_netmask&f_dhcpd_enable=$f_dhcpd_enable" .
"&dhcpd_startip=$dhcpd_startip&dchpd_endip=$dchpd_endip&dhcp_lease=$dhcp_lease";
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,0);//要求结果保存到字符串中还是输出到屏幕上,参数为1,不返回到屏幕
curl_setopt($ch,CURLOPT_HTTPHRADER,$head);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$curlPost);
$data=curl_exec($ch);
curl_close($ch);
echo "data=$data";
echo "lan-ipaddr=$lan_ipaddr";
echo "lan-netmask=$lan_netmask";
echo "f_dchpd_enable=$f_dhcpd_enable";
echo "dhcpd_startip=$dhcpd_startip";
echo "dhcpd_endip=$dhcpd_endip";
echo "dhcp_lease=$dhcp_lease";
?>
$url="http://192.168.0.1/tomato.cgi"; ?
你知道他需要接受什么样的数据吗?
先换成 php 程序进行测试
$url="http://192.168.0.1/tomato.cgi"; ?
你知道他需要接受什么样的数据吗?
先换成 php 程序进行测试
他那是用番茄刷的路由器wrt,估计挺难换php测试了,呵呵