Skip to content

Go微信接口请求客户端. A WeChat API client for go.

License

Notifications You must be signed in to change notification settings

Xavier-Lam/go-wechat

Repository files navigation

go-wechat

Build Status Coverage Status Go Report Card

go-wechat 是一个Go拓展,提供了一个用于与微信API进行交互的客户端。它允许您向微信发送API请求并处理响应。目前支持公众号小程序.

English Readme

功能:

  • 自动存储和更新Access token
  • Access token失效后自动刷新并重试
  • 完整的单元测试
  • 易用灵活的接口

快速开始

  • 调用封装API

      package main
    
      import (
      	"encoding/json"
    
          "github.com/Xavier-Lam/go-wechat"
          "github.com/Xavier-Lam/go-wechat/caches"
          "github.com/Xavier-Lam/go-wechat/officialaccount"
      )
    
      func main() {
          auth := wechat.NewAuth("appId", "appSecret")
          cache := caches.NewDummyCache()
          conf := client.Config{Cache: cache}
          oa := officialaccount.New(auth, conf)
          jsConfig, err := oa.Js.GetJsConfig("url", officialaccount.JsConfig{})
          data, err := json.Marshal(jsConfig)
      }
    
  • 调用原始API

      package main
    
      import (
          "github.com/Xavier-Lam/go-wechat"
          "github.com/Xavier-Lam/go-wechat/caches"
          "github.com/Xavier-Lam/go-wechat/client"
      )
    
      func main() {
          auth := wechat.NewAuth("appId", "appSecret")
          cache := caches.NewDummyCache()
          conf := client.Config{Cache: cache}
          w := client.New(auth, conf)
          data := map[string]interface{}{
              "scene": "value1",
              "width": 430,
          }
          resp, err := w.PostJson("/wxa/getwxacodeunlimit", data, true)
      }
    
  • 获取最新token

      w := client.New(auth, conf)
      token, err := w.GetAccessToken()
      ak := token.GetAccessToken()
    

About

Go微信接口请求客户端. A WeChat API client for go.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages