Giter Club home page Giter Club logo

Comments (7)

ktmud avatar ktmud commented on July 18, 2024

就是这个意思

在 2013年9月8日星期日,maye696 写道:

现在我的理解是node监听的是3000端口,而微信后台url不能填写如222.26.155.22:3000之类的网址,那我是否应该通过反向代理将3000映射到80端口以便在微信后台添加222.26.155.22即可正确相应token?
我的理解是否正确?


Reply to this email directly or view it on GitHubhttps://github.com//issues/61
.

from weixin-robot.

carly1987 avatar carly1987 commented on July 18, 2024

求指教
我在百度云 bae上的nodejs环境 用webot。 然后 无法app.listen(80); 会说端口被占用。 然后 微信的接口信息 配置那边也一直不通过。 反向代理 要怎么弄呢?webot.watch(app, { token: 'layzer', path: '/wechat' }); 我的wechat在lib文件夹下。 这里的path是否要改成 ‘./lib/webchat’ 反正改后 也没通过。 卡住了,求指教~~~

from weixin-robot.

ktmud avatar ktmud commented on July 18, 2024

@carly1987 请参考 BAE 的官方文档: http://developer.baidu.com/wiki/index.php?title=docs/cplat/rt/node.js

app.js 监听的端口必须是 BAE 环境变量中指定的端口:

app.listen(process.env.APP_PORT);

百度会自动帮你做反向代理

webot.watch 里面的 path 参数是你提供给微信的接口 url 里面的 path ,例如,如果填的是 /wechat ,微信后台的接口信息配置就要填:

http://yourapp.duapp.com/wechat

from weixin-robot.

carly1987 avatar carly1987 commented on July 18, 2024

// 接管消息请求
webot.watch(app, { token: 'layzer', path: '/wechat' });
// 启动 Web 服务
// 微信后台只允许 80 端口
app.listen(process.env.APP_PORT);

这样以后 报了500错误。error: listen port number over one

------------------ 原始邮件 ------------------
发件人: "Jesse Yang";[email protected];
发送时间: 2013年9月15日(星期天) 晚上9:41
收件人: "node-webot/weixin-robot"[email protected];
抄送: "carly"[email protected];
主题: Re: [weixin-robot] 请问微信公共平台后台url无法添加含有端口的网址,应该怎么解决? (#61)

webot.watch 里面的 path 参数是你提供给微信的接口 url 里面的 path ,例如,如果填的是 /wechat ,微信后台的借口信息配置就要填:
http://yourapp.duapp.com/wechat

Reply to this email directly or view it on GitHub.

from weixin-robot.

carly1987 avatar carly1987 commented on July 18, 2024
/*
 * BAE Node.js application demo
 */
 /* Port which provided by BAE platform */
var port = process.env.APP_PORT;
 /*
 * Create an HTTP server
 * which is as similar as http://nodejs.org/api/http.html mentioned
 */
 /*var http = require('http');
 var server = http.createServer(function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html'
    });
     var body = '<html>' + '<body>' +
               '<h1>Welcome to Baidu Cloud!</h1>' +port+
               '</body>' + '</html>';
     res.end(body);
});
 server.listen(port);*/
 /* Enjoy it! */
var express = require('express');
var webot = require('./lib/weixin');
var app = express();
// 指定回复消息
/*webot.set('hi', '你好');
 webot.set('subscribe', {
  pattern: function(info) {
    return info.is('event') && info.param.event === 'subscribe';
  },
  handler: function(info) {
    return '欢迎订阅微信机器人';
  }
});*/
// 接管消息请求
webot.watch(app, { token: 'layzer', path: '/wechat' });
// 启动 Web 服务
// 微信后台只允许 80 端口
app.listen(port);
 // 如果你不想让 node 应用直接监听 80 端口
// 可以尝试用 nginx 或 apache 自己做一层 proxy
//app.listen(process.env.PORT);
//app.enable('trust proxy');

from weixin-robot.

carly1987 avatar carly1987 commented on July 18, 2024

我把代码最终修改为
var express = require('express');
var port = process.env.APP_PORT;
var webot = require('./lib/weixin');

var app = express();
app.get('/', function(req, res, next) {
var message = req.query.message;
webot.reply({
text: message,
}, function(err, info) {
if (err) return res.json({ r: err });
res.json({
r: 0,
reply: info.reply
});
});
});
webot.watch(app, { token: 'layzer', path: '/wechat' });

app.listen(port);

也终于 不报错了

但是 微信验证还是没通过。 说 服务器 没有正式通过tohen

url: http://lazyer.duapp.com/wechat
Token : lazyer

------------------ 原始邮件 ------------------
发件人: "Jesse Yang";[email protected];
发送时间: 2013年9月15日(星期天) 晚上9:41
收件人: "node-webot/weixin-robot"[email protected];
抄送: "carly"[email protected];
主题: Re: [weixin-robot] 请问微信公共平台后台url无法添加含有端口的网址,应该怎么解决? (#61)

webot.watch 里面的 path 参数是你提供给微信的接口 url 里面的 path ,例如,如果填的是 /wechat ,微信后台的借口信息配置就要填:
http://yourapp.duapp.com/wechat

Reply to this email directly or view it on GitHub.

from weixin-robot.

bnpysse avatar bnpysse commented on July 18, 2024

可以使用ngrok来实现穿透80端口的问题。

from weixin-robot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.