-1
我正在移植一個依賴於curl提供的cookiejar來獲取cookie並在後續調用中使用它的php代碼段。我面臨着用Apache Camel在Java中實現相同代碼的問題。我無法讀取返回的cookie。有什麼建議麼?有沒有在Apache Camel + Java中存儲和檢索Cookie的設施(如curl和php中的cookiejar)
PHP的片斷如下:
$ckfile = tempnam ("/tmp", "CURLCOOKIE");
....
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
// Executing the ch
$result['EXE'] = curl_exec($ch);
$result['INF'] = curl_getinfo($ch);
$result['ERR'] = curl_error($ch);
//print_r($result['EXE']);