Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
wechat-nodejs-sdk
Advanced tools
Readme
提供给Nodejs端开发微信公众号相关的SDK, 目前只支持使用redis作为存储介质。
import WeixinSdk from 'weixin-sdk'
import { logger } from '../helpers/logger'
import redisClient from './redis-client'
module.exports.weixinSdk = new WeixinSdk({ ...config.weixin, client: redisClient, logger: logger })
module.exports.weixinSdk = new WeixinSdk(config.weixin)
Note
config.weixin中可能需要配置的参数
参数 | 说明 | 默认值 |
---|---|---|
noncestr | 随机数,用于验证消息的确来自微信服务器(可以参考https://mp.weixin.qq.com/wiki) | Wm3WZYTPz0wzccnW |
appId | 微信为每个公众号生成的唯一的随机数 | wx7f70a1cadda24881 |
appSecret | 和appId组合使用,也是基于每个公众号 | 5da26c0c6d1b9cf5cef5baf76ee784a8 |
granType | 向微信服务器请求的类型,目前只用于获取Token,所以使用默认值 | client_credential |
accessTokenUrl | 向微信服务器请求Token的Url | https://api.weixin.qq.com/cgi-bin/token |
ticketUrl | 向微信请求Tiket的Url | https://api.weixin.qq.com/cgi-bin/ticket/getticket |
tokenKey | 缓存到Storage的微信Token名称,根据不同环境下修改成自己的名字 | BFF:WEIXIN:TOKEN |
appToken | 用于验证消息的确来自微信服务器(可以参考https://mp.weixin.qq.com/wiki) | 1111111 |
cacheKey | 缓存到Memory Cache的微信Ticket字段名称 | BFF:RIDER:WEIXIN:TICKET |
init()
初始化微信相关的所有预置条件,比如初始化Redis客户端(因为目前采用redis缓存Token),微信OAuth客户端
getWeixinToken()
用于获取微信基础Token,这个有别于网页Token,每天限制请求次数(1000次)
getWebsiteSignature()
用于微信公众测试号验证服务器有效性。开发者提交信息后,微信服务器将发送GET请求到填写的服务器地址URL上,我们需要按照微信指定的算法去生成一个返回值给微信服务器
getSdkSignature()
用于调用微信SDK而需要针对每个URL生成唯一的签名,当使用wx.config的时候会用到
getWeixinOpenId()
用于根据微信回调code获取用户的openid
getAuthorizeURL()
生成一个微信的认证回调URL
FAQs
some API related to weixin in nodejs
We found that wechat-nodejs-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).