npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wechat-nodejs-sdk

v1.0.8

Published

some API related to weixin in nodejs

Downloads

4

Readme

Packages用途

提供给Nodejs端开发微信公众号相关的SDK, 目前只支持使用redis作为存储介质。

Usage

  1. 安装: yarn add wechat-nodejs-sdk
  2. 使用:
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

API

init()

初始化微信相关的所有预置条件,比如初始化Redis客户端(因为目前采用redis缓存Token),微信OAuth客户端

getWeixinToken()

用于获取微信基础Token,这个有别于网页Token,每天限制请求次数(1000次)

getWebsiteSignature()

用于微信公众测试号验证服务器有效性。开发者提交信息后,微信服务器将发送GET请求到填写的服务器地址URL上,我们需要按照微信指定的算法去生成一个返回值给微信服务器

getSdkSignature()

用于调用微信SDK而需要针对每个URL生成唯一的签名,当使用wx.config的时候会用到

getWeixinOpenId()

用于根据微信回调code获取用户的openid

getAuthorizeURL()

生成一个微信的认证回调URL