util

package
v0.0.0-...-e31aad9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 6, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AESDecryptMsg

func AESDecryptMsg(ciphertext []byte, aesKey []byte) (random, rawXMLMsg, appID []byte, err error)

AESDecryptMsg ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId] 参考:github.com/chanxuehong/wechat.v2

func AESEncryptMsg

func AESEncryptMsg(random, rawXMLMsg []byte, appID string, aesKey []byte) (ciphertext []byte)

AESEncryptMsg ciphertext = AES_Encrypt[random(16B) + msg_len(4B) + rawXMLMsg + appId] 参考:github.com/chanxuehong/wechat.v2

func CloseProxy

func CloseProxy()

CloseProxy 关闭代理

func DecodeWithCommonError

func DecodeWithCommonError(response []byte, apiName string) (err error)

DecodeWithCommonError 将返回值按照CommonError解析

func DecryptMsg

func DecryptMsg(appID, encryptedMsg, aesKey string) (random, rawMsgXMLBytes []byte, err error)

DecryptMsg 消息解密

func EncryptMsg

func EncryptMsg(random, rawXMLMsg []byte, appID, aesKey string) (encrtptMsg []byte, err error)

EncryptMsg 加密消息

func GetCurrTs

func GetCurrTs() int64

GetCurrTs return current timestamps

func GetHTTPClient

func GetHTTPClient() (httpClient *http.Client)

GetHTTPClient 获取 HTTPClient,如果有设置代理,则根据代理的地址生成代理的httpClient

func GetHTTPSClient

func GetHTTPSClient(rootCa, key string) (*http.Client, error)

GetHTTPSClient CA证书

func HTTPGet

func HTTPGet(uri string) ([]byte, error)

HTTPGet get 请求

func MD5Sum

func MD5Sum(txt string) (sum string)

MD5Sum 计算 32 位长度的 MD5 sum

func OpenProxy

func OpenProxy()

OpenProxy 打开代理

func PostFile

func PostFile(fieldname, filename, uri string) ([]byte, error)

PostFile 上传文件

func PostJSON

func PostJSON(uri string, obj interface{}) ([]byte, error)

PostJSON post json 数据请求

func PostJSONWithRespContentType

func PostJSONWithRespContentType(uri string, obj interface{}) ([]byte, string, error)

PostJSONWithRespContentType post json数据请求,且返回数据类型

func PostMultipartForm

func PostMultipartForm(fields []MultipartFormField, uri string) (respBody []byte, err error)

PostMultipartForm 上传文件或其他多个字段

func PostXML

func PostXML(uri string, obj interface{}) ([]byte, error)

PostXML perform a HTTP/POST request with XML body

func PostXMLWithTLS

func PostXMLWithTLS(uri string, obj interface{}, ca, key string) ([]byte, error)

PostXMLWithTLS perform a HTTP/POST request with XML body and TLS

func RandomStr

func RandomStr(length int) string

RandomStr 随机生成字符串

func SetProxy

func SetProxy(url string)

SetProxy 设置代理URL

func Signature

func Signature(params ...string) string

Signature sha1签名

Types

type CommonError

type CommonError struct {
	ErrCode int64  `json:"errcode"`
	ErrMsg  string `json:"errmsg"`
}

CommonError 微信返回的通用错误json

func (CommonError) Err

func (c CommonError) Err() error

Error 返回错误信息

func (CommonError) IsInvalidCredential

func (c CommonError) IsInvalidCredential() bool

IsInvalidCredential ...

type MultipartFormField

type MultipartFormField struct {
	IsFile    bool
	Fieldname string
	Value     []byte
	Filename  string
}

MultipartFormField 保存文件或其他字段信息

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL