Purpose: Other services use pull mode, perform RPC communication through rpcx, and obtain related WeChat tokens. The user's WeChat public account is used by a third-party platform to swipe the related tokens of the public account platform and the managed public account appid. The service cannot be stopped for more than 10 minutes (the instance automatically Pull up crontab). Mainly brush the component_access_token and preauthcode of the third-party public account, and the authorizer_access_token and authorizer_refresh_token of the public account.
Benefits: The WeChat public account third-party platform relay server is used to refresh the public account platform's own token and the hosted public account token, allowing developers to only focus on the business logic of the WeChat public account third-party platform, while the business instance can be restarted repeatedly. It will not have any impact on hosted official accounts
Storage method: etcd stores rpc service address, WeChat official account platform and official account token, uses etcd's ttl feature, and watches and refreshes
1. 服务启动后,立即读取etcd中的所有微信公众平台和公众号数据,加载到内存中。 并监听所有token
Standard go get
:
$ go get - v - u github . com / 1046102779 / wx_relay_server
type WxRelayServer struct {}
// 获取公众号平台基本信息,包括appid,token等信息
func ( t * WxRelayServer ) GetOfficialAccountPlatformInfo ( in * pb. OfficialAccountPlatform , out * pb. OfficialAccountPlatform ) error
// 存储托管公众号的token相关信息
func ( t * WxRelayServer ) StoreOfficialAccountInfo ( in * pb. OfficialAccount , out * pb. OfficialAccount ) error
// 获取公众号token信息, 用于公众号第三方平台发起公众号的托管业务
func ( t * WxRelayServer ) GetOfficialAccountInfo ( in * pb. OfficialAccount , out * pb. OfficialAccount ) error
// 刷新component_verify_ticket, 并同时中继服务器刷公众号第三方平台的其他token
func ( t * WxRelayServer ) RefreshComponentVerifyTicket ( in * pb. ComponentVerifyTicket , out * pb. ComponentVerifyTicket ) error
希望与大家一起成长,有任何该服务运行或者代码问题,可以及时找我沟通,喜欢开源,热爱开源, 欢迎多交流
联系方式:[email protected]