亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

返回200,但是刷不出評論,已上代碼,求指正!

var http = require('http');

var querystring = require('querystring');


var postData = querystring.stringify({

'content':'如果能夠評論,說明成功了',

'cid': 348

});


var options = {

hostname: 'www.xianlaiwan.cn',

port: 80,

path: '/course/docomment',

method: 'POST',

header: {

'Accept':'application/json, text/javascript, */*; q=0.01',

? ? ? ? 'Accept-Encoding':'gzip, deflate',

? ? ? ? 'Accept-Language':'zh-CN,zh;q=0.8',

? ? ? ? 'Connection':'keep-alive',

? ? ? ? 'Content-Length': postData.length,

? ? ? ? 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',

? ? ? ? 'Cookie':'復制',

? ? ? ? 'Host':'www.xianlaiwan.cn',

? ? ? ? 'Origin':'http://www.xianlaiwan.cn',

? ? ? ? 'Referer':'http://www.xianlaiwan.cn/comment/348',

? ? ? ? 'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36',

? ? ? ? 'X-Requested-With':'XMLHttpRequest'

}

};



var req = http.request(options, function(res){

console.log('Status: ' + res.statusCode);

console.log('Headers: ' + JSON.stringify(res.headers))

res.on('data', function(chunk){

console.log(Buffer.isBuffer(chunk));

console.log(typeof chunk);

});

res.on('end', function(){

console.log('commit success!');

})

});


req.on('error', function(e){

console.log('error: ' + e.message);

})

req.write(postData);

req.end();


正在回答

2 回答

你的postData中的'cid'現在已經改為'mid':8837。我的錯誤是method寫錯了,導致他默認為get方式,就沒有寫入評論,我的現在好了,你改了再試試。

0 回復 有任何疑惑可以回復我~
#1

ks13287555 提問者

非常感謝!
2016-06-21 回復 有任何疑惑可以回復我~

同是返回200,但是卻沒有評論,現在解決了嗎

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
進擊Node.js基礎(一)
  • 參與學習       219329    人
  • 解答問題       982    個

本視頻教程帶你揭開Node.js的面紗,帶你走進一個全新世界

進入課程

返回200,但是刷不出評論,已上代碼,求指正!

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號