Documentation ¶
Index ¶
- Variables
- func GetSortedQueryStr(params map[string]string) (sortedQueryStr string)
- type Client
- func (c *Client) Exec(params map[string]string) (success bool, result string, err error)
- func (c *Client) IsValid() bool
- func (c *Client) MakeRequestBody(params map[string]string) (body io.Reader, err error)
- func (c *Client) Post(params map[string]string) (resp *http.Response, err error)
- func (c *Client) SignHMAC(params map[string]string) (signature string)
- func (c *Client) SignMD5(params map[string]string) (signature string)
- func (c *Client) UpdateCommonParams(params map[string]string)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefCommonParams is default common parameters of alidayu APIs DefCommonParams = map[string]string{ "format": "json", "v": "2.0", "sign_method": "md5", } )
Functions ¶
func GetSortedQueryStr ¶
GetSortedQueryStr sorts the keys of parameters and generate sorted query string which can be used to sign(MD5 or HMAC_MD5).
Types ¶
type Client ¶
type Client struct { AppKey string // App Key AppSecret string // App Secret UseHTTPS bool // Use HTTPS URL or not http.Client }
Client contains app key and secret and provides method to post HTTP request like http.Request.
func (*Client) Exec ¶
Exec executes the REST API and get the response. It's a wrapper of Post().
Params: params: map that contains parameters of REST API. See official docs to fill the parameters. Returns: success: If REST API succeeds. result: Raw response string of REST API.
func (*Client) MakeRequestBody ¶
MakeRequestBody makes the HTTP request body by given parameters for each REST API.
func (*Client) Post ¶
Post does the HTTP post for each REST API.
Params: params: map that contains parameters of REST API. See official docs to fill the parameters. Returns: resp: HTTP Response. Do not forget to call resp.Body.Close() after use.
func (*Client) UpdateCommonParams ¶
UpdateCommonParams updates the given parameters by merge default common parameters.
Click to show internal directories.
Click to hide internal directories.