代码放在本地做测试,一个简单的登录,但是curl post不过去数据,也取不回这个success
然后curl代码如下:
header("content-Type: text/html; charset=UTF-8");
$login_url="http://127.0.0.3/35/doLogin.php";
$data = array("username" => "demo", "password" => "demo","is_ajax"=>"1");
$data_string = json_encode($data);
//提交登录表单请求
$ch=curl_init($login_url);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,0);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Requested-With: XMLHttpRequest"));
$data=curl_exec($ch);
curl_close($ch);
var_dump(json_decode($data,true));
?>
访问curl代码打印出来是NULL