nodejs 发送 post 请求 带参数

var http = require('http');
var querystring = require('querystring');


var post_data = querystring.stringify({
         product : 'club',
         sign : 'ddddddddddddddd',
         sender: '发送者的名字:超级管理员',
         uids : ['ffwq@qq.com', 'ffqwf@www.com'],
         msg : 'wwww'
});

var options = {
    host: '10.11.442.33',
    port: 80,
    path: '/ww1',
    method: 'POST'
};


var req = http.request(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('BODY: ' + chunk);
  });
});

// write data to request body
req.write(post_data + "\n");
req.end();
posted @ 2011-11-20 13:04  方子尚  阅读(4080)  评论(0编辑  收藏  举报