我想发布如下卷曲的形式与hubot。
curl -s -H "Content-type: application/x-www-form-urlencoded" -H “X-AAA: aaa” -H “X-BBB: bbb” -X POST -d @${ACCOUNT_FILE} https://xxx/login
${ACCOUNT_FILE} is written.
login_id=loginid&password=password
我写了以下脚本但是,它不起作用。
auth.coffee
request = require 'request'
cheerio = require 'cheerio'
require('request').debug = true
module.exports = (robot) ->
loginUrl = ‘https://xxx/login’
headers = {
‘X-AAA’: ‘aaa’
‘X-BBB’: ‘bbb’
}
getAuth = (msg, loginid, password) ->
options =
url: loginUrl
method: "POST"
timeout: 2000
headers: headers
form: {
'login_id': loginid
'password': password
}
request options, (err, res, body) ->
$ = cheerio.load body
console.log($)
msg.send "body is"
msg.send $
robot.hear /getauth/i, (msg) ->
getAuth msg, 'loginid', 'password'
如何修改此脚本?