【问题标题】:Force CURL request to not look for a response PHP强制 CURL 请求不寻找响应 PHP
【发布时间】:2017-03-12 17:26:00
【问题描述】:

编辑:正确的做法是从 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);
}

【问题讨论】:

  • 为什么不等待回复呢?您是否忘记在 Node-RED 流中添加 http-response 节点?
  • 你是绝对正确的 hardillb,只有响应表单节点红色更容易。我不知道为什么我从来没有注意到左边的那个。
  • 至于其他帖子...我很欣赏这些链接。当响应为零时,我刚刚从 CURL 得到混合结果。感谢大家的宝贵时间!

标签: php curl node-red


【解决方案1】:

如 cmets 中所述。

正确的解决方案是确保您的 http-in 节点与 Node-RED 流中的 http-response 节点配对

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-27
    • 2013-10-25
    • 2013-11-18
    • 2016-06-11
    相关资源
    最近更新 更多