Answer the question
In order to leave comments, you need to log in
How can I send post data and read it?
Actually, you need to transfer data to node via php.
I used the curl library
$curl = curl_init();
$data = array('message' => 'test');
curl_setopt($curl, CURLOPT_URL, "http://localhost:8888");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_exec($curl);
var app = require('http').createServer(handler)
, io = require('socket.io').listen(app)
//, fs = require('fs')
//, qs = require('querystring')
app.listen(8888);
console.log('START');
function handler(req, res)
{
console.log('HANDLER');
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + res.headers);
console.log("message: " + req.body.message);
//console.log(res);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question