Documentation ¶
Overview ¶
weixin.go
Index ¶
- Variables
- func GetNonceStr(n int) string
- func InvalidateForWeiXin(token string, r *http.Request, w http.ResponseWriter)
- func JSONMarshal(v interface{}, safeEncoding bool) ([]byte, error)
- func MakeSignature(token, timestamp, nonce string) string
- func Map2XMLBytes(m map[string]string) ([]byte, error)
- func NewTLSHttpClient(certFile, keyFile string) (*http.Client, error)
- func SignForWXPay(parameters map[string]string, apiKey string, fn func() hash.Hash) string
- func XML2Map(stream io.Reader) (map[string]string, error)
Constants ¶
This section is empty.
Variables ¶
var NONCE_LETTERS_TOTAL = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
用于生成随机字符串 代码摘自: http://blog.csdn.net/luciswe/article/details/45900373
Functions ¶
func GetNonceStr ¶
func InvalidateForWeiXin ¶
func InvalidateForWeiXin(token string, r *http.Request, w http.ResponseWriter)
func JSONMarshal ¶
注意当把AuthCodeURL生成的url用作菜单的url时,微信服务器端会把”非法字法的错误信息,如:& 被json.marshal转化为\u0026; 可微信不认这个,报\u0026为非法字符!” 现在写一个方法将微信认为非法的转义后字符再转化回原字符
func MakeSignature ¶
func Map2XMLBytes ¶
对于value值没有转义,只是加了CDATA保护,即然xml不再解释它,我就先不加转义了.
func NewTLSHttpClient ¶
创建应用证书之httpClient. NewTLSHttpClient 创建支持双向证书认证的 http.Client 引自:https://github.com/chanxuehong/wechat/blob/master/mch/http_client.go 参考:https://github.com/bigwhite/experiments/blob/master/gohttps/6-dual-verify-certs/client.go http://stackoverflow.com/questions/18187136/net-http-ignoring-system-proxy-settings http://blog.csdn.net/luciswe/article/details/45890713 现在没有对服务端身体进行验证即InsecureSkipVerify=true,以后有必要再加。
func SignForWXPay ¶
引自:https://github.com/chanxuehong/wechat/blob/master/mch/sign.go 写的非常清晰,我就不再造车轮了,感恩前辈。 微信支付签名.
parameters: 待签名的参数集合 apiKey: API密钥 fn: func() hash.Hash, 如果 fn == nil 则默认用 md5.New
Types ¶
This section is empty.