Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

初始化错误,不应该有参数 token #13

Open
zsy619 opened this issue Dec 6, 2020 · 3 comments
Open

初始化错误,不应该有参数 token #13

zsy619 opened this issue Dec 6, 2020 · 3 comments

Comments

@zsy619
Copy link

zsy619 commented Dec 6, 2020

func New(appId, appSecret string) *Message {
message := &Message{
Request: Request{Token: ""},
AccessToken: AccessToken{AppId: appId, AppSecret: appSecret},
}
// 要刷新token
token, _ := message.AccessToken.Fresh()
message.Request.Token = token
return message
}

@zsy619
Copy link
Author

zsy619 commented Dec 6, 2020

初始化应该在加一个参数,是否获取token,在创建菜单时需要初始化token
而进行消息回复不需要

@zsy619
Copy link
Author

zsy619 commented Dec 6, 2020

func New(appId, appSecret string, refreshToken bool) *Message {
message := &Message{
Request: Request{Token: ""},
AccessToken: AccessToken{AppId: appId, AppSecret: appSecret},
}
//判定是否刷新token
// 创建菜单需要刷新token
// 自动消息回复不需要刷新token
if refreshToken {
token, _ := message.AccessToken.Fresh()
message.Request.Token = token
}
return message
}

@zsy619
Copy link
Author

zsy619 commented Dec 6, 2020

原始传入的token是无用的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant