2 개의 요청을 cURL로 처리하려고합니다. 첫 번째 요청은 로그인인데, 아직 로그 된 상태에서 두 번째 요청을하기 위해 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 데이터에 사용하여 양식을 실행하고 있습니다. 서버가 같은 나에게 오류를 촬영하고, 양식 처리는 여전히 ... 같은 페이지에
내 접속을 발생하지만, 나도 몰라 : 귀하의 요청을 처리하는 동안
는 예외가 발생했습니다 . 우리는 예외를 기록했다. ..
나에게 도움이되지 않는다. 어떤 아이디어가 있습니까?
감사합니다.
아파치의 로그를 살펴볼 수 있습니까? 아마도 더 많은 정보를 제공 할 수 있습니다. – Jaay
당신은 예외가 발생한 서비스 개발자에게 문의해야 할 수도 있습니다. 대부분 POST 매개 변수가 유효하지 않거나 무언가입니다. – MarioP
예외가 무엇인지 오류 메시지를 제공하는 사람에게 물어보십시오. – jterry