Comments (7)
就是这个意思
在 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.
求指教
我在百度云 bae上的nodejs环境 用webot。 然后 无法app.listen(80); 会说端口被占用。 然后 微信的接口信息 配置那边也一直不通过。 反向代理 要怎么弄呢?webot.watch(app, { token: 'layzer', path: '/wechat' }); 我的wechat在lib文件夹下。 这里的path是否要改成 ‘./lib/webchat’ 反正改后 也没通过。 卡住了,求指教~~~
from weixin-robot.
@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.
// 接管消息请求
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.
/*
* 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.
我把代码最终修改为
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.
可以使用ngrok来实现穿透80端口的问题。
from weixin-robot.
Related Issues (20)
- Doc里面似乎有个小错误 HOT 2
- handler里使用异步事件 HOT 1
- 请问新出的语音辨识接口加上了吗? HOT 5
- 语音识别接口还是有bug HOT 5
- 链接菜单没有跳转 HOT 4
- 经常会出现204请求 HOT 1
- 微信多次发送消息 HOT 4
- 能否拿到发信的人的ip地址? HOT 3
- 机器人自动回复时, 回复内容可以在别的回调函数里面吗(wechat单独使用,指定res.reply是可以的) HOT 4
- 在handler中return图文信息的时候url无法带入多个参数 HOT 2
- 微博也做了类似的post推送机制,能否兼容一下? HOT 3
- 该公众号暂时无法提供服务,请稍后再试 HOT 4
- 请教下 如何把yaml修改为json么? HOT 2
- 有计划支持安全模式么? HOT 4
- 代码全是express3.x的,有没有express4.x以上版本? HOT 1
- 多客服系统没有接入么? HOT 5
- 配置正常,但是没有自动回复 HOT 1
- 为什么老会显示don't konw what you are saying HOT 2
- 规则库
- 国务院与该项目的合作
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from weixin-robot.