fix: wechat verify

This commit is contained in:
Rogee
2025-01-10 19:44:24 +08:00
parent ab576706e7
commit 52c17b63bb
13 changed files with 83 additions and 92 deletions

View File

@@ -39,6 +39,9 @@ type Client struct {
appSecret string
token string
aesKey string
verifyKey string
verifyValue string
}
func New(options ...Options) *Client {
@@ -53,6 +56,13 @@ func New(options ...Options) *Client {
return we
}
func (we *Client) VerifySite(key string) (string, error) {
if key == we.verifyKey {
return we.verifyValue, nil
}
return "", errors.New("verify failed")
}
func (we *Client) Verify(signature, timestamp, nonce string) error {
params := []string{signature, timestamp, nonce, we.token}
sort.Strings(params)