toutiao

package
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 AccessToken

type AccessToken struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   int64  `json:"expires_in"`
	Error       int64  `json:"error"`
	ErrCode     int64  `json:"errcode"`
	ErrMsg      string `json:"errmsg"`
	Message     string `json:"message"`
}

AccessToken model

type Client

type Client struct {
	AppId  string
	Secret string
}

Client Client

func NewClient

func NewClient(appId, secret string) *Client

NewClient NewClient 传入appId和appSecret

func (*Client) CodeToSession added in v0.6.8

func (c *Client) CodeToSession(code string) (sessionData *SessionData, err error)

CodeToSession 通过code换取session_key 和 openId

func (*Client) Decrypt added in v0.6.8

func (c *Client) Decrypt(sessionKey, encryptedData string, iv string) (*TTAppletUserInfo, error)

解密敏感信息

func (*Client) GetAccessToken

func (c *Client) GetAccessToken() (accessData *AccessToken, err error)

GetAccessToken 获得头条的接口登录凭证

type SessionData added in v0.6.8

type SessionData struct {
	SessionKey      string `json:"session_key"`
	Openid          string `json:"openid"`
	AnonymousOpenid string `json:"anonymous_openid"`
	Unionid         string `json:"unionid"`
	Error           int64  `json:"error"`
	ErrCode         int64  `json:"errcode"`
	ErrMsg          string `json:"errmsg"`
	Message         string `json:"message"`
}

SessionData model

type TTAppletUserInfo added in v0.6.8

type TTAppletUserInfo struct {
	OpenID    string `json:"openId"`
	NickName  string `json:"nickName"`
	Gender    int    `json:"gender"` //0: 未知;1:男性;2:女性
	City      string `json:"city"`
	Province  string `json:"province"`
	Country   string `json:"country"`
	AvatarURL string `json:"avatarUrl"`
	Watermark struct {
		Timestamp int64  `json:"timestamp"`
		AppID     string `json:"appid"`
	} `json:"watermark"`
}

TTAppletUserInfo 敏感用户信息

Jump to

Keyboard shortcuts

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