Example #1
0
// 上传离线图片
func (this *WebQQ) UploadOfflinePic(peeruin Uin, pic io.Reader) (v *ResultOfflinePic, err error) {
	form := &bytes.Buffer{}
	formdata := multipart.NewWriter(form)
	formdata.WriteField("callback", "parent.EQQ.Model.ChatMsg.callbackSendPic")
	formdata.WriteField("locallangid", "2052")
	formdata.WriteField("clientversion", "1409")
	formdata.WriteField("uin", this.id_str)
	formdata.WriteField("skey", this.getCookie(util.MustParseUrl(_OFFLINE_UPLOAD_URL), "skey"))
	formdata.WriteField("appid", _WEBQQ_APPID)
	formdata.WriteField("peeruin", peeruin.String())
	formdata.WriteField("vfwebqq", this.vfwebqq)
	formdata.WriteField("fileid", util.ToString(fileid))
	formdata.WriteField("senderviplevel", "0")
	formdata.WriteField("reciverviplevel", "0")
	fileid++
	picdata, _ := formdata.CreateFormFile("file", "1.png")
	io.Copy(picdata, pic)
	formdata.Close()
	res, err := this.client.Post(_CFACE_UPLOAD_URL+"?time="+util.JsCurrentTime(), formdata.FormDataContentType(), form)
	if err != nil {
		return
	}
	defer res.Body.Close()
	b, err := ioutil.ReadAll(res.Body)
	if err != nil {
		return
	}
	sb := offlinePatten.FindStringSubmatch(string(b))
	if len(sb) > 1 {
		v = &ResultOfflinePic{}
		json.Unmarshal([]byte(sb[1]), v)
	}
	return
}
Example #2
0
// 上传自定义表情
func (this *WebQQ) UploadCustomFace(pic io.Reader) (v string, err error) {
	form := &bytes.Buffer{}
	formdata := multipart.NewWriter(form)
	formdata.WriteField("from", "control")
	formdata.WriteField("f", "EQQ.Model.ChatMsg.callbackSendPicGroup")
	formdata.WriteField("vfwebqq", this.vfwebqq)
	formdata.WriteField("fileid", util.ToString(fileid))
	fileid++
	picdata, _ := formdata.CreateFormFile("custom_face", "1.png")
	io.Copy(picdata, pic)
	formdata.Close()
	res, err := this.client.Post(_CFACE_UPLOAD_URL+"?time="+util.JsCurrentTime(), formdata.FormDataContentType(), form)
	if err != nil {
		return
	}
	defer res.Body.Close()
	b, err := ioutil.ReadAll(res.Body)
	if err != nil {
		return
	}
	sb := cfacePatten.FindStringSubmatch(string(b))
	if len(sb) > 1 {
		v = sb[1]
	}
	return
}
Example #3
0
func (this *User) Login() (err error) {
	res, err := this.get("/login/ajax?"+(url.Values{
		"callback": {"jQuery18309862185863312334_" + util.JsCurrentTime()},
		"username": {this.Username},
		"password": {this.Password},
		"verify":   {},
	}).Encode(), "")
	rst, _ := ioutil.ReadAll(res.Body)
	res.Body.Close()
	var obj map[string]string
	json.Unmarshal(rst[41:len(rst)-1], &obj)
	if obj["status"] != "success" {
		return errors.New(obj["message"])
	}
	return
}
Example #4
0
// 通用API接口(GET)
func (this *WebQQ) api(api string, args ...interface{}) (body []byte, err error) {
	val := url.Values{
		"vfwebqq": {this.vfwebqq},
		"t":       {util.JsCurrentTime()},
	}
	l := len(args) - 1
	for i := 0; i < l; i += 2 {
		val.Add(args[i].(string), fmt.Sprint(args[i+1]))
	}
	res, err := this.getWithReferer(_API_URL+api+"?"+val.Encode(), _API_REFERER)
	if err != nil {
		return
	}
	body, err = ioutil.ReadAll(res.Body)
	res.Body.Close()
	return
}
Example #5
0
func (this *User) Sign() (err error) {
	res, err := this.get("/user/daysign?callback=jQuery18300392456746451165_"+util.JsCurrentTime(), SITE_BASE)
	if err != nil {
		return
	}
	rst, err := ioutil.ReadAll(res.Body)
	if err != nil {
		return
	}
	res.Body.Close()
	var obj map[string]string
	json.Unmarshal(rst[41:len(rst)-1], &obj)
	if obj["status"] != "success" {
		return errors.New(obj["message"])
	}
	return
}
Example #6
0
// 通用channel接口(GET)
func (this *WebQQ) channel(api string, args ...interface{}) (body []byte, err error) {
	val := url.Values{
		"clientid":   {this.clientid},
		"psessionid": {this.psessionid},
		"t":          {util.JsCurrentTime()},
	}
	l := len(args) - 1
	for i := 0; i < l; i += 2 {
		val.Add(args[i].(string), fmt.Sprint(args[i+1]))
	}
	res, err := this.getWithReferer(fmt.Sprintf("%s%s?%s", _CHANNEL_URL, api, val.Encode()), _CHANNEL_REFERER)
	if err != nil {
		return
	}
	body, err = ioutil.ReadAll(res.Body)
	res.Body.Close()
	return
}
Example #7
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
}