user

package
v1.0.0-beta.4 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package user 用户

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSessionKey

func CheckSessionKey(ctx *miniprogram.Miniprogram, params url.Values) (resp []byte, err error)

校验服务器所保存的登录态 session_key 是否合法。为了保持 session_key 私密性,接口不明文传输 session_key,而是通过校验登录态签名完成。

See: https://developers.weixin.qq.com/minigame/dev/api-backend/open-api/login/auth.checkSessionKey.html

GET https://api.weixin.qq.com/wxa/checksession?access_token=ACCESS_TOKEN&signature=SIGNATURE&openid=OPENID&sig_method=SIG_METHOD

Example
package main

import (
	"fmt"
	"net/url"

	"github.com/fastwego/miniprogram"
	"github.com/fastwego/miniprogram/minigame/apis/user"
)

func main() {
	var ctx *miniprogram.Miniprogram

	params := url.Values{}
	resp, err := user.CheckSessionKey(ctx, params)

	fmt.Println(resp, err)
}
Output:

func Code2Session

func Code2Session(ctx *miniprogram.Miniprogram, params url.Values) (resp []byte, err error)

登录凭证校验。通过 wx.login 接口获得临时登录凭证 code 后传到开发者服务器调用此接口完成登录流程。更多使用方法详见 小程序登录。

See: https://developers.weixin.qq.com/minigame/dev/api-backend/open-api/login/auth.code2Session.html

GET https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code

Example
package main

import (
	"fmt"
	"net/url"

	"github.com/fastwego/miniprogram"
	"github.com/fastwego/miniprogram/minigame/apis/user"
)

func main() {
	var ctx *miniprogram.Miniprogram

	params := url.Values{}
	resp, err := user.Code2Session(ctx, params)

	fmt.Println(resp, err)
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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