怎样用Node.js的npm request来调用REST_API?
z764350169 发布于2016-02 浏览:1867 回复:1
0
收藏

var options = {
                uri: 'http://vop.baidu.com/server_api',
                method: 'POST',
                headers: {"Content-Type": "application/json"},
                json:{
                    'format':'amr',
                    'rate':'8000',
                    'channel':1,
                    'token':token,//1
                    'cuid':userId,//2
                    'url':url//3这三个已经在前面定义
                }
            };
            function callback(error, res, body)  {
                if (!error && res.statusCode == 200{
                    response.send(info);
                }
    
            }
            request(options, callback);


这样写对吗?但是总是参数错误.....求助~~

补充我参考过得一些网址

http://yijiebuyi.com/blog/8221eb14c8482e7efd1868946e99ea7c.html

http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed4fece76310579135480ddd276b97844b22918448e435061e5a25a4ec66644b598f84616d05aa4e58e0fa2b33605f76a09bbed91781fdc574699f27423657c41605d36ffc89047b9a71c31cb2f245f0ba866ad2f38ec4df22119712436d8086ce01464edd6f86486cb5f18e48630751aea86d25a9562f68882331e71aa5a665324196f7ad4b4cb53dd11157dced62a73f62a212d7081b5517e20eef53007576bb127be8444c5cd3b601&p=c3658b5686cc41ac5da6ca2d021486&newp=c9759a45d5c616fc57efcd3e505f9e231610db2151d4d01028&user=baidu&fm=sc&query=js+Content-Type%3A+application/json&qid=c95c00fb0026d706&p1=1


收藏
点赞
0
个赞
共1条回复 最后由用户已被禁言回复于2022-04
#20半君0回复于2016-02

由于人力有限,目前rest api只提供java和C++代码的demo,其余平台使用请自行探索,谢谢~

0
TOP
切换版块