Documentation ¶
Index ¶
- type Config
- type Service
- func (s *Service) AddReceivers(userIDs ...string)
- func (s *Service) Send(ctx context.Context, subject, content string) error
- func (s *Service) WaitForOneOffVerification(serverURL string, devMode bool, callback verificationCallbackFunc) error
- func (s *Service) WaitForOneOffVerificationWithServer(server *http.Server, devMode bool, callback verificationCallbackFunc) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { AppID string AppSecret string Token string EncodingAESKey string Cache cache.Cache }
Config is the Service configuration.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service encapsulates the WeChat client along with internal state for storing users.
func (*Service) AddReceivers ¶
AddReceivers takes user ids and adds them to the internal users list. The Send method will send a given message to all those users.
func (*Service) Send ¶
Send takes a message subject and a message content and sends them to all previously set users.
func (*Service) WaitForOneOffVerification ¶
func (s *Service) WaitForOneOffVerification(serverURL string, devMode bool, callback verificationCallbackFunc) error
WaitForOneOffVerification waits for the verification call from the WeChat backend. It uses an internal ReadHeaderTimeout of 20 seconds to avoid blocking the caller for too long (potential slow loris attack). In case that you want to use a different timeout, you can use the WaitForOneOffVerificationWithServer method instead. It allows you to specify a custom server.
Should be running when (re-)applying settings in wechat configuration.
Set devMode to true when using the sandbox.
See https://developers.weixin.qq.com/doc/offiaccount/en/Basic_Information/Access_Overview.html
func (*Service) WaitForOneOffVerificationWithServer ¶
func (s *Service) WaitForOneOffVerificationWithServer(server *http.Server, devMode bool, callback verificationCallbackFunc) error
WaitForOneOffVerificationWithServer allows you to use WaitForOneOffVerification with a fully custom HTTP server.
Should be running when (re-)applying settings in wechat configuration.
Set devMode to true when using the sandbox.
See https://developers.weixin.qq.com/doc/offiaccount/en/Basic_Information/Access_Overview.html