Ejemplo n.º 1
0
// 通用API接口(POST)
func (this *WebQQ) postApi(api string, args ...interface{}) (body []byte, err error) {
	val := url.Values{
		"r": {util.ToJson(
			append(args, "vfwebqq", this.vfwebqq)...,
		)},
	}
	l := len(args) - 1
	for i := 0; i < l; i += 2 {
		val.Add(args[i].(string), fmt.Sprint(args[i+1]))
	}
	res, err := this.postFormWithReferer(_API_URL+api, _API_REFERER, val)
	if err != nil {
		return
	}
	body, err = ioutil.ReadAll(res.Body)
	res.Body.Close()
	return
}
Ejemplo n.º 2
0
// 通用channel接口(POST)
func (this *WebQQ) postChannel(api string, args ...interface{}) (body []byte, err error) {
	val := url.Values{
		"r": {util.ToJson(
			append(args, "clientid", this.clientid, "psessionid", this.psessionid)...,
		)},
		"clientid":   {this.clientid},
		"psessionid": {this.psessionid},
	}
	l := len(args) - 1
	for i := 0; i < l; i += 2 {
		val.Add(args[i].(string), fmt.Sprint(args[i+1]))
	}
	res, err := this.postFormWithReferer(_CHANNEL_URL+api, _CHANNEL_REFERER, val)
	if err != nil {
		return
	}
	body, err = ioutil.ReadAll(res.Body)
	res.Body.Close()
	return
}
Ejemplo n.º 3
0
/*
	[2014.2.6] 1.获取文件信息
	GET http://web2.cgi.weiyun.com/wy_share_v2.fcg
	cmd:view_share
	g_tk:
	callback:CALLBACK
	data:{"req_header":{"cmd":"view_share","main_v":11,"proto_ver":10006,"sub_v":1,"encrypt":0,"msg_seq":1,"source":30111,"appid":30111,"client_ip":"127.0.0.1","token":"4d3754f563ad04a56fece81bbcc83302"},"req_body":{"share_key":"79ff0e64bd9c88cbd53a0ae72c14401c"}}
	_:1391326126322

	RET:
	try{CALLBACK({"rsp_body":{"createtime":"2013-08-28 12:40:43","dir_list":[],"dlskey":"74c726bfa1e9978207b41e9b312fa5d8709a1c5c7099774009af37429e0c58fd40e9cb52d7b84819","downcnt":54,"file_list":[{"file_id":"bdbc4714-b322-437b-87b3-25c978fcfa37","file_name":"jd-gui.exe","file_size":"719872"}],"note_info":null,"pdir_key":"80a2162d77c92765438ca4ef1d170515","res_type":0,"share_flag":0,"share_key":"79ff0e64bd9c88cbd53a0ae72c14401c","sharename":"jd-gui.exe","short_url":"http://url.cn/PVX6FN","show_store":true,"storecnt":0,"uin":756458112,"viewcnt":87},"rsp_header":{"ret":0}})}catch(e){};

*/
func GetShareInfo(sharekey string) (shareInfo ShareInfo, err error) {
	res, err := http.Get(_WEIYUN_VIEW_SHARE_URL +
		url.QueryEscape(util.ToJson(
			"req_header", struct {
				Cmd      string `json:"cmd"`
				MainV    int32  `json:"main_v"`
				ProtoVer int32  `json:"proto_ver"`
				SubV     int32  `json:"sub_v"`
				Encrypt  int32  `json:"encrypt"`
				MsgSeq   int32  `json:"msg_seq"`
				Source   int32  `json:"source"`
				Appid    int32  `json:"appid"`
				ClientIp string `json:"client_ip"`
				Token    string `json:"token"`
			}{"view_share", 11, 10006, 1, 0, 1, 30111, 30111, "127.0.0.1", "4d3754f563ad04a56fece81bbcc83302"},
			"req_body", struct {
				ShareKey string `json:"share_key"`
			}{sharekey},
		)) + "&_=" + util.JsCurrentTime())
	if err != nil {
		return
	}
	b, err := ioutil.ReadAll(res.Body)
	res.Body.Close()
	if err != nil {
		return
	}
	rsp := &struct {
		RspBody   ShareInfo `json:"rsp_body"`
		RspHeader struct {
			Ret int32 `json:"ret"`
		} `json:"rsp_header"`
	}{}
	err = json.Unmarshal(b[13:len(b)-13], rsp) // try{CALLBACK({...})}catch(e){};
	shareInfo = rsp.RspBody
	return
}