如何通过php的curl模拟ajax请求,获取其返回值
1个回答
展开全部
您好:
$str = array
(
'Auth'=>'admin',
'CustomerNumber'=>$customerNumber,
'Addtime'=>$addtime ,
'City'=>$city,
'Suppliers'=>$suppliers,
'Domain'=>$domain
);
$url = "http://www.xxx.com/xxx.php";
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $str );
$return = curl_exec ( $ch );
curl_close ( $ch );
那边用$_POST接一下,大体就是这样的。
$str = array
(
'Auth'=>'admin',
'CustomerNumber'=>$customerNumber,
'Addtime'=>$addtime ,
'City'=>$city,
'Suppliers'=>$suppliers,
'Domain'=>$domain
);
$url = "http://www.xxx.com/xxx.php";
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url );
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $str );
$return = curl_exec ( $ch );
curl_close ( $ch );
那边用$_POST接一下,大体就是这样的。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询