当我使用curl CLI时,它正在工作,但是当我使用curl PHP时,它无效:/
<?php
exec('curl -X POST -H "Cookie: JSESSIONID='.$cookie.'" -H "Cache-Control: no-cache" -H "Content-Type: application/x-www-form-urlencoded" -d \'f1=value1&f2=value2&f3='. clean($content) .'\' http://localhost/loginAction.do');
?>
但是这个不起作用..
<?php
// Transcription CLI to cURL PHP
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => array(
'f1' => 'value1',
'f2' => 'value2' ,
'f3' => $content
),
CURLOPT_HTTPHEADER => array('Cache-Control: no-cache',
'Content-Type: application/x-www-form-urlencoded',
'Cookie: JSESSIONID='.$cookie
),
CURLOPT_URL => 'http://localhost/loginAction.do'
));
$output = curl_exec($ch);
curl_close ($ch);
?>
有人能解释我为什么吗?我想我什么也没忘记 提前谢谢。