如何检索php发送到socket.io的curl数据?

时间:2017-06-17 21:57:22

标签: socket.io

这是我的socket.io extract

var httpServer = https.createServer(ssl, function(req,res) {
    console.log(req.method, req.url);
}).listen(999);
var io  = require('socket.io').listen(httpServer,{log:false});

现在,当我尝试通过curl进行交流时

<?php
function notifyNode($url, $port) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
    curl_setopt($ch, CURLOPT_PORT, $port);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
    curl_setopt($ch, CURLOPT_POST, true);
    $data = array('a' => 'hellwo world', 'b' => 'zaza');
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    curl_exec($ch);
    curl_close($ch);
}    
notifyNode('https://example.com', 999);

这很好用:我的节点中有方法和url。 但是如何在socket.io中检索$ data?

0 个答案:

没有答案