
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
wechat-nodejs-sdk
Advanced tools
提供给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
The npm package wechat-nodejs-sdk receives a total of 2 weekly downloads. As such, wechat-nodejs-sdk popularity was classified as not popular.
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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.