收藏
回答

nodejs通过API【自定义菜单】=》【创建接口】,创建失败没有错误代码。有碰到过这情况的朋友吗?

var http = require('https')
var post_data ={
    "button": [
        {
            "name": "下载APP",
            "sub_button": [
                {
                    "type": "view",
                    "name": "主下载地址",
                    "url": "https://wx.baidu.cn/app/"
                },
                {
                    "type": "view",
                    "name": "备用下载地址",
                    "url": "https://m-ios.baidu.cn/fy2w"
                }
            ]
        }
    ]
}

var access_token = '12312312214214214124214124124124'
var options = {
    hostname: 'api.weixin.qq.com',
    path: `/cgi-bin/menu/create?access_token=${access_token}`,
    method: 'POST',
    headers: {'Content-Type': 'application/json; charset=UTF-8'}
};


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

req.on('error', function (e) {
    console.log('problem with request: ' + e.message);
});

req.write(JSON.stringify(post_data));   
req.end();
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签