wechatopenplatform

package module
v0.0.0-...-6798356 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2021 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

wechat-open-platform

Build Status

Golang 微信开放平台 SDK

done

获取用户信息 AccessToken(需持久化 防止超过请求限制) RefreshToken

todo

usage

获取用户信息
package mina

import (
	WOP "github.com/solarhell/wechat-open-platform"
)

func main() {
	ak, err := WOP.GetAccessToken("appId", "appSecret", "code")
	if err != nil {
		// err handle
		...
	}
	
	ui, err := WOP.GetUserInfo(ak.AccessToken, ak.Openid)
	if err != nil {
		// err handle
		...
	}
	
	
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnectWechatServer = errors.New("err connect Wechat server")
)

Functions

func RefreshTokenURL

func RefreshTokenURL(appId, refreshToken string) (s string, err error)

func TokenURL

func TokenURL(appId, appSecret, code string) (s string, err error)

Types

type AccessToken

type AccessToken struct {
	CommonResponse
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	Openid       string `json:"openid"`
	Scope        string `json:"scope"`
	Unionid      string `json:"unionid,omitempty"`
}

func GetAccessToken

func GetAccessToken(appId, appSecret, code string) (ak AccessToken, err error)

func RefreshToken

func RefreshToken(appId, refreshToken string) (ak AccessToken, err error)

type CommonResponse

type CommonResponse struct {
	Errcode int    `json:"errcode,omitempty"`
	Errmsg  string `json:"errmsg,omitempty"`
}

type UserInfo

type UserInfo struct {
	CommonResponse
	Openid     string   `json:"openid"`
	Nickname   string   `json:"nickname"`
	Sex        int      `json:"sex"` // 普通用户性别,1为男性,2为女性
	Language   string   `json:"language"`
	City       string   `json:"city"`
	Province   string   `json:"province"`
	Country    string   `json:"country"`
	Headimgurl string   `json:"headimgurl,omitempty"`
	Privilege  []string `json:"privilege"`
	Unionid    string   `json:"unionid"`
}

func GetUserInfo

func GetUserInfo(accessToken, openId string) (ui UserInfo, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址