Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xavier-lam/go-wechat
Go微信接口请求客户端. A WeChat API client for go.
https://github.com/xavier-lam/go-wechat
go golang wechat weixin wx
Last synced: 27 days ago
JSON representation
Go微信接口请求客户端. A WeChat API client for go.
- Host: GitHub
- URL: https://github.com/xavier-lam/go-wechat
- Owner: Xavier-Lam
- License: mit
- Created: 2023-07-20T10:40:32.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-07-27T11:10:13.000Z (over 1 year ago)
- Last Synced: 2023-07-27T12:28:31.951Z (over 1 year ago)
- Topics: go, golang, wechat, weixin, wx
- Language: Go
- Homepage:
- Size: 102 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.en.md
Awesome Lists containing this project
README
# go-wechat
[![Build Status](https://github.com/Xavier-Lam/go-wechat/actions/workflows/ci.yml/badge.svg)]((https://github.com/Xavier-Lam/go-wechat/actions?query=workflows%3ACI))
[![Coverage Status](https://codecov.io/gh/Xavier-Lam/go-wechat/branch/master/graph/badge.svg)](https://codecov.io/gh/Xavier-Lam/go-wechat)
[![Go Report Card](https://goreportcard.com/badge/github.com/Xavier-Lam/go-wechat)](https://goreportcard.com/report/github.com/Xavier-Lam/go-wechat)**go-wechat** is a Go package that provides a client for interacting with the WeChat API. It allows you to send API requests to WeChat and handle the response. Currently, it supports only API requests for [Official account](https://developers.weixin.qq.com/doc/offiaccount/Getting_Started/Overview.html) and [Mini program](https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/).
[中文版](README.md)
Features:
* Automatically store and update credentials
* Automatically refresh credential and retry after a credential corrupted
* Full unittest coverage
* Easy use and flexible APIs## Quickstart
* Call encapsulated Apispackage 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)
}* Call api directly
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)
}* Get latest access token
w := client.New(auth, conf)
token, err := w.GetAccessToken()
ak := token.GetAccessToken()