簡體   English   中英

PHP CURL超時?

[英]PHP CURL timing out?

每次都超時。 如何解決?

<?
$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);
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM