Example #1
0
func PushMessage(message *UMengMessage) map[string]interface{} {
	var sign = sign("POST", UMENG_MSG_SEND_API_URL, message.JSON(), message.AppSecret)
	var client = http.NewClient()
	client.SetMethod("POST")
	client.SetURLString(UMENG_MSG_SEND_API_URL + "?sign=" + sign)
	client.SetBody(message.JSON())

	var results, _ = client.DoJsonRequest()
	return results
}
Example #2
0
func RequestWithKey(appKey, appSecret string, param ITaoBaoParam) (results map[string]interface{}, err error) {
	var p = make(map[string]string)
	p["timestamp"] = time.Now().Format("2006-01-02 15:04:05")
	p["format"] = "json"
	p["v"] = "2.0"
	p["sign_method"] = "md5"
	p["app_key"] = appKey
	p["method"] = param.APIName()

	if len(param.ExtJSONParamName()) > 0 {
		p[param.ExtJSONParamName()] = param.ExtJSONParamValue()
	}

	var ps = param.Params()
	if ps != nil {
		for key, value := range ps {
			p[key] = value
		}
	}

	var c = http.NewClient()
	c.SetMethod("POST")
	c.SetURLString(TAO_BAO_OPEN_API_URL)

	var keys = make([]string, 0, len(p))
	for key, value := range p {
		c.SetParam(key, value)
		keys = append(keys, key)
	}
	sort.Strings(keys)

	c.SetParam("sign", sign(appSecret, keys, p))

	results, err = c.DoJsonRequest()
	return results, err
}