每次都會超時。如何解決它?PHP CURL超時?
<?
$curl = curl_init("https://gstdealerdaily.fitsvcs.com/siteminderagent/forms/login.fcc");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
print $result;
每次都會超時。如何解決它?PHP CURL超時?
<?
$curl = curl_init("https://gstdealerdaily.fitsvcs.com/siteminderagent/forms/login.fcc");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($curl);
curl_close($curl);
print $result;
您需要添加更多的cURL函數才能工作。
<?php
$target_url="https://gstdealerdaily.fitsvcs.com/siteminderagent/forms/login.fcc";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,4);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$html = curl_exec($ch);
$html = preg_replace("#(<\s*a\s+[^>]*href\s*=\s*[\"'])(?!http)([^\"'>]+) ([\"'>]+)#",'$1'.$target_url.'$2$3', $html);
echo $html;
curl_close($ch);
var_dump($ch);
?>
該代碼的回報: 資源(2)型(未知)的 – user1724365
傾銷捲曲的錯誤,我得到:捲曲的錯誤:connect()的計時出來了! – user1724365
您確定cURL已啓用並在您的服務器上運行嗎? @ user1724365 – Azhar
該URL超時我...嘗試不同勢一個 – Solrac