Node.js 免费点击拨号(CTD,VOIP回拨)

跟风做了个Node.js版本.

命令行使用方法:

node call.js 主叫号码 被叫号码  

源代码:

/**
 * CTD Node Client Ver
 * 2012-10-07
 */
var p1=process.argv[2];  
var p2=process.argv[3];

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

function sendPost(p1,p2){  
    var contents=querystring.stringify({
        'method':'StartCall',
        'phone1':p1,
        'phone2':p2,
        'url':'http://220.194.62.63/ctdStatusRecv.php',
        'StatusFilter':'0,1,2,3'
    });

    var options={
        host:'www.buptmba.org',
        path:'/index.jsp',
        method:'POST',
        headers:{
            'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
            'Accept-Charset':'UTF-8,*;q=0.5',
            'Accept-Encoding':'gzip,deflate,sdch',
            'Accept-Language':'zh-CN,zh;q=0.8',
            'Cache-Control':'max-age=0',
            'Connection':'keep-alive',
            'Content-Length':contents.length,
            'Content-Type':'application/x-www-form-urlencoded',
            'Host':'www.buptmba.org',
            'Origin':'http://www.buptmba.org',
            'Referer':'http://www.buptmba.org/index.jsp',
            'User-Agent':'Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.79 Safari/537.4'
        }
    };

    var req=http.request(options,function(res){
        res.setEncoding('utf8');
        res.on('data',function(data){
            console.log('Done');
        });
    });

    req.write(contents);
    req.end();
}

sendPost(p1,p2);