注册公众平台登录
https://mp.weixin.qq.com
jinzhentaohb@gmail.com wuji5890302
注册 微信公众平台接口测试帐号申请
因为没有认证的公众号,所以申请测试账号
测试号信息
1 2
   | appID wxde374247d5e85784 appsecret dbd6f17e21577b68113b141eae8172f2
   | 
 
接口配置信息 
1 2
   | URL https://wechat.jinzt.top  微信后台回调通知我们自己的web服务器的域名 Token weixin 我自己设置的token
   | 
 
JS接口安全域名
1
   | games.jinzt.top  客户端的域名(客户端会使用jssdk)
   | 
 
第一步 本地搭建一个web服务器
安装windows版本nginx
在html目录下新建 wechat.jinzt.top 目录,然后在其目录下新建 index.html 内容为
1 2 3 4 5 6 7 8 9 10 11
   | <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(runoob.com)</title> </head> <body>     <h1>我的第一个标题</h1>     <p>我的第一个段落。</p> </body> </html>
   | 
 
修改 nginx.conf 
1 2 3 4 5 6 7 8 9
   |    # wechat.jinzt.top  server {   	listen 80; 	server_name  wechat.jinzt.top; 	location / {            root   html/wechat.jinzt.top.;            index  index.html index.htm;        } }
   | 
 
通过 http://localhost/wechat.jinzt.top/ 即可访问
第二步 域名解析
要想同步域名访问就得有一个域名,在阿里买一个域名 jinzt.top,添加一个域名解析
1
   | ipv4 wechat.jinzt.top 解析到外网centos主机 144.34.170.63
   | 
 
并且给 jinzt.top 申请一个免费 ssl 证书,下载nginx版本
frp配置
** 远程centos主机144.34.170.63配置 **
vim frps.ini
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
   | [common] bind_port = 7000 #kcp_bind_port = 7000 vhost_http_port = 8080 #vhost_https_port = 443 # 自定义二级域名 subdomain_host = frp.jinzt.top
  # 设定一个token,frp客户端要连接本服务器必须配置一样的token token = 12345678
  # 端口白名单 allow_ports = 5000-8000
  tcp_mux = true max_pool_count = 5
  # web面板dashboard dashboard_addr = 0.0.0.0 dashboard_port = 7500 dashboard_user = admin dashboard_pwd = 123456
  # 配置log log_file = ./frps.log
   | 
 
./frps -c ./frps.ini
本地frpc
修改 frpc.ini 添加一个web配置项
1 2 3 4 5 6
   | [test_wechat] type = http local_ip = 127.0.0.1 local_port = 80 locations = / custom_domains = wechat.jinzt.top
   | 
 
启动frpc
1
   | .\frpc.exe -c ./frpc.ini
   | 
 
通过域名访问
现在就可以通过http://wechat.jinzt.top:8080/进行访问了,但是这里不支持ssl,而且后面必须带一个8080端口进行访问,接下来就通过nginx来解决
ssl访问及8080端口隐藏
在centos机安装nginx
1 2 3 4 5 6
   | yum install nginx yum install lrzsz cd /etc/nginx mkdir cert cd cert rz 分别上传2476612_jinzt.top.pem 和 2476612_jinzt.top.key
   | 
 
配置ssl 隐藏8080https://www.jianshu.com/p/b4988508faa3
vim /etc/nginx/sites-enabled/default
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
   | 
  # ssl server {         listen       443 ssl;         server_name  wechat.jinzt.top;
          ssl_certificate       /etc/nginx/cert/2547643_wechat.jinzt.top.pem;         ssl_certificate_key   /etc/nginx/cert/2547643_wechat.jinzt.top.key;
          ssl_session_cache    shared:SSL:1m;         ssl_session_timeout  5m;
          ssl_ciphers  HIGH:!aNULL:!MD5;         ssl_prefer_server_ciphers  on;
          location    / {             proxy_pass http://wechat.jinzt.top:8080;         }
          proxy_set_header Host $host;         proxy_set_header X-Real-IP $remote_addr;         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;         #proxy_set_header X-Forwarded-Proto  $scheme;
          #error_log  /var/log/nginx/wildcard.jinzt.top.log  debug;         #access_log /var/log/nginx/wildcard.jinzt.top.access.log main;                            }
  ``
 
  建议公众号开发者使用中控服务器统一获取和刷新Access_token,其他业务逻辑服务器所使用的access_token均来自于该中控服务器,不应该各自去刷新,否则容易造成冲突,导致access_token覆盖而影响业务
  ## [官方文档](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1445241432)
  ## 微信web开发者工具 - [下载](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1455784140)
 
  ## 支付 - [tvrcgo/weixin-pay](https://github.com/tvrcgo/weixin-pay) - [befinal/node-tenpay](https://github.com/befinal/node-tenpay) - [supersheep/wechat-pay](https://github.com/supersheep/wechat-pay/tree/master/lib)
 
  ## 文章 - [SilenceHVK/wechatByNode](https://github.com/SilenceHVK/wechatByNode) - [sofish/wechat.js](https://github.com/sofish/wechat.js) - [liuxing/koa2-wechat](https://github.com/liuxing/koa2-wechat/tree/master/lesson4)
 
 
  ## 准备 - 1.nodejs - 2.mysql
 
  安装nodejs [下载](http://nodejs.cn/download/)
  安装koa ```bash npm install --save koa
 
  | 
 
简单实用 创建 app.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
   | var koa =require('koa'); var app=new koa();
 
 
 
 
 
 
 
 
 
 
 
  app.use( async (ctx)=>{      ctx.body='你好 koa2.x'; })
  app.listen(3000);
  | 
 
启动server
安装 mongodb
###
         
        
    
    
        
    最后更新时间:
        
        这里可以写作者留言,标签和 hexo 中所有变量及辅助函数等均可调用,示例:
https://jinzt.github.io/posts/f66864f1.html