强制 CURL 请求不寻找响应 PHP
Force CURL request to not look for a response PHP
编辑:正确的做法是发送来自 Node-red 的响应,如下面的 hardillb 指出。
我的 CURL 请求工作正常且即时,但我只需要让页面访问 url 而不是等待响应。我已经尝试了所有我能想到的组合,但我的浏览器仍然等待服务器响应,直到超时。
$url = 'http://example.com:1880/get?temperature='.$temperature;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 1);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
// 3. execute and fetch the resulting HTML output
$output = curl_exec($ch);
// 4. free up the curl handle
curl_close($ch);
}
如评论中所述。
正确的解决方案是确保您的 http-in 节点与 Node-RED 流程中的 http-response 节点配对
编辑:正确的做法是发送来自 Node-red 的响应,如下面的 hardillb 指出。
我的 CURL 请求工作正常且即时,但我只需要让页面访问 url 而不是等待响应。我已经尝试了所有我能想到的组合,但我的浏览器仍然等待服务器响应,直到超时。
$url = 'http://example.com:1880/get?temperature='.$temperature;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 1);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
// 3. execute and fetch the resulting HTML output
$output = curl_exec($ch);
// 4. free up the curl handle
curl_close($ch);
}
如评论中所述。
正确的解决方案是确保您的 http-in 节点与 Node-RED 流程中的 http-response 节点配对