0
Я разрабатываю для некоторых данных сообщения API над nodejs. У меня проблемы. если я отправляю данные по https, тогда php обрабатывает пустые данные. Кто-нибудь знает? Спасибо.nodejs post пустые данные через соединение ssl
a.js =>
//https unauth disable
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';
var http = require('https');
var post_req = null,
post_data = '{ "dataid":"81","userid":"29" }';
var post_options = {
hostname: 'www.domain.com',
port : '443',
path : '/get.php',
method : 'POST',
headers : {
'Content-Type': 'application/json;',
'Content-Length': post_data.length
}
};
debugger;
post_req = http.request(post_options, function (res) {
//console.log('STATUS: ' + res.statusCode);
//console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('Response: ', chunk);
});
});
post_req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
debugger;
post_req.write(JSON.stringify(post_data));
debugger;
post_req.end();
И это блок кода PHP.
get.php =>
print_r($_POST);