我目前正在研究脚本,我需要制作一些卷曲文章。问题是,脚本将需要执行很多这些请求,恐怕会影响性能和响应时间。请注意,我只需要使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'。 –