我正在用cURL做2個請求。第一個請求是登錄我,並保存一個txt文件,以使第二個請求仍然存在。
第一部分工作像一個魅力,第二部分不起作用。
有我的代碼。
$lien = 'https://mysite.com/login';
$postfields = array(
'username' => 'test',
'password' => 'test'
);
$path_cookie = 'connexion.txt';
if (!file_exists(realpath($path_cookie))) touch($path_cookie);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $lien);
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields);
curl_setopt($curl, CURLOPT_COOKIEJAR, realpath($path_cookie));
$return = curl_exec($curl);
echo($return);
curl_close($curl);
$lien2 = 'https://mysite.com/myform';
$postfields2 = array(
'data1' => 'test123',
'data2' => 'Account',
'sort' => '3',
'fileFormat' => '0',
'timezone' => 'Eastern+Standard+Time',
'zeroRated' => 'true',
'startDate' => '2013-05-01',
'endDate' => '2013-05-31'
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $lien2);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postfields2);
curl_setopt($curl, CURLOPT_COOKIEFILE, realpath($path_cookie));
$return = curl_exec($curl);
echo $return;
curl_close($curl);
unlink(realpath($path_cookie));
我正在使用$ _post數據的第二部分來執行表單。表單處理髮生在同一個網頁...
我的Connexion公司仍然有效,但我不知道,服務器是拍攝我的錯誤,如:
處理您的請求時發生異常。我們記錄了例外情況..
它並沒有幫助我。任何人有一個想法?
謝謝。
你可以看看apache的日誌,也許它會提供更多的信息 – Jaay
你可能需要詢問你正在調用的服務的開發者是否發生了什麼異常。很可能POST參數是無效的或某事。 – MarioP
詢問誰提供錯誤消息是什麼例外。 – jterry