qq

package
Version: v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessData

type AccessData struct {
	AccessToken  string `json:"access_token"`
	ExpiresIn    int    `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
}

AccessData access token response

type Client

type Client struct {
	AppId  string
	Secret string
}

Client QQ oauth client

func NewClient

func NewClient(appId, secret string) *Client

NewClient return a new qq oauth client

func (*Client) GetAccessTokenByCode

func (m *Client) GetAccessTokenByCode(code, redirectUrl string) (accessToken string, err error)

GetAccessTokenByCode 根据code获取accessToken 主要用到PC网站上

第二步
之前还有获取code的方法 https://wiki.connect.qq.com/%E4%BD%BF%E7%94%A8authorization_code%E8%8E%B7%E5%8F%96access_token

func (*Client) GetOpenIdAndUnionIdByAccessToken

func (m *Client) GetOpenIdAndUnionIdByAccessToken(accessToken string) (openId string, unionId string, err error)

GetOpenIdAndUnionIdByAccessToken 返回openid和unionid

主要用到pc网上
第三步

func (*Client) GetQQUser

func (m *Client) GetQQUser(openId, accessToken string) (user *QUser, err error)

GetQQUser return qq user

by openId
app端可直接使用此方法
pc网站调用时,这是第四步

type OpenIdData

type OpenIdData struct {
	ClientId string `json:"client_id"`
	OpenId   string `json:"openid"`
	UnionId  string `json:"unionid"`
}

OpenIdData openId response

type QUser

type QUser struct {
	Ret        int64  `json:"ret"`
	Msg        string `json:"msg"`
	NickName   string `json:"nickname"`
	FigureUrl1 string `json:"figureurl_qq_1"` //QQ头像1 40*40
	FigureUrl2 string `json:"figureurl_qq_2"` //QQ头像2 100*100
}

QUser QQ返回的用户

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL