Ai
1 Star 0 Fork 0

五度曲橙/golang-wechat-sdk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
officialaccount.go 1.97 KB
一键复制 编辑 原始数据 按行查看 历史
五度曲橙 提交于 2021-06-11 11:03 +08:00 . first commit
package officialaccount
import (
"gitee.com/qucheng/golang-wechat-sdk/credential"
"gitee.com/qucheng/golang-wechat-sdk/officialaccount"
offConfig "gitee.com/qucheng/golang-wechat-sdk/officialaccount/config"
opContext "gitee.com/qucheng/golang-wechat-sdk/openplatform/context"
"gitee.com/qucheng/golang-wechat-sdk/openplatform/officialaccount/js"
"gitee.com/qucheng/golang-wechat-sdk/openplatform/officialaccount/oauth"
)
//OfficialAccount 代公众号实现业务
type OfficialAccount struct {
//授权的公众号的appID
appID string
*officialaccount.OfficialAccount
}
//NewOfficialAccount 实例化
//appID :为授权方公众号 APPID,非开放平台第三方平台 APPID
func NewOfficialAccount(opCtx *opContext.Context, appID string) *OfficialAccount {
officialAccount := officialaccount.NewOfficialAccount(&offConfig.Config{
AppID: opCtx.AppID,
EncodingAESKey: opCtx.EncodingAESKey,
Token: opCtx.Token,
Cache: opCtx.Cache,
})
//设置获取access_token的函数
officialAccount.SetAccessTokenHandle(NewDefaultAuthrAccessToken(opCtx, appID))
return &OfficialAccount{appID: appID, OfficialAccount: officialAccount}
}
// PlatformOauth 平台代发起oauth2网页授权
func (officialAccount *OfficialAccount) PlatformOauth() *oauth.Oauth {
return oauth.NewOauth(officialAccount.GetContext())
}
// PlatformJs 平台代获取js-sdk配置
func (officialAccount *OfficialAccount) PlatformJs() *js.Js {
return js.NewJs(officialAccount.GetContext(), officialAccount.appID)
}
//DefaultAuthrAccessToken 默认获取授权ak的方法
type DefaultAuthrAccessToken struct {
opCtx *opContext.Context
appID string
}
//NewDefaultAuthrAccessToken New
func NewDefaultAuthrAccessToken(opCtx *opContext.Context, appID string) credential.AccessTokenHandle {
return &DefaultAuthrAccessToken{
opCtx: opCtx,
appID: appID,
}
}
//GetAccessToken 获取ak
func (ak *DefaultAuthrAccessToken) GetAccessToken() (string, error) {
return ak.opCtx.GetAuthrAccessToken(ak.appID)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/qucheng/golang-wechat-sdk.git
git@gitee.com:qucheng/golang-wechat-sdk.git
qucheng
golang-wechat-sdk
golang-wechat-sdk
a0c205eb99dc

搜索帮助