1

cURL を使用して Web サイトにログインしようとしています。私のコードは他の Web サイトでは機能しますが、この Web サイトでは curl_exec でハングします。致命的なエラー: 最大実行時間が 30 秒を超えました。

同様の質問が寄せられていることを知っており、それらをすべて調べました...考えられるスクリプトのすべての組み合わせと変更を試みましたが、運がありませんでした。助言がありますか?

$username = 'myUsername';
$password = 'myPassword';

$url="https://www.centraldispatch.com/login/"; 
$cookie="cookie.txt"; 

if (! file_exists($cookie) || ! is_writable($cookie))
{
    echo 'Cookie file missing or not writable.';
    exit;
}


$postFields = array(
  'Username' => $username,
  'Password' => $password,
  'r' => '' //a hidden field in the form
);

$postdata = http_build_query($postFields);

$ch = curl_init(); 
curl_setopt ($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_VERBOSE, 1);   
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");  
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); 
curl_setopt ($ch, CURLOPT_REFERER, $url); 

curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); 
curl_setopt ($ch, CURLOPT_POST, 1); 
$result = curl_exec ($ch); //code hangs here

echo $result;  
curl_close($ch);
4

1 に答える 1