代碼放在本地做測(cè)試,一個(gè)簡(jiǎn)單的登錄,但是curl post不過(guò)去數(shù)據(jù),也取不回這個(gè)success
然后curl代碼如下:
<?phpheader("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); //提交登錄表單請(qǐng)求 $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)); ?>
訪問(wèn)curl代碼打印出來(lái)是NULL