我目前正在研究腳本,我需要製作一些捲曲文章。問題是,腳本將需要執行很多這些請求,恐怕會影響性能和響應時間。請注意,我只需要使curl文章,我不需要答案。 這裏是代碼我使用:發送curl而不等待回覆php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $post_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_USERAGENT, 'api');
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_FORBID_REUSE, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt($ch, CURLOPT_DNS_CACHE_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_close($ch);
我使用正確的代碼?此代碼是否只發布請求並關閉,不等待任何響應? 謝謝你們提前幫忙。
您cUrl作者:PHP腳本,如果你不等待怎麼可能你使用'$ return'結果?如果你不使用它,那麼把你的代碼放在後臺任務中。還有'header('Connection:close')' –
@LawrenceCherone我只是犯了複製它的錯誤!除了$ return之外,目前的代碼還在做這項工作嗎? –
它應該做什麼?你得到了'$ curl',它應該是'$ ch'。 –