예제 #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
}
예제 #2
0
파일: WebQQ.go 프로젝트: pa001024/reflex
// 登录 [2013.8.27]
func (this *WebQQ) Login() (err error) {
	defer util.Catch(&err)
	// [1] login_sig
	this.login_sig, err = this.ptlogin_login_sig()
	util.Try(err)
check:
	// [2] check
	_, code, err := this.ptlogin_check()
	util.Try(err)
	// [3] login
	pturl, err := this.ptlogin_login(code)
	if err != nil {
		goto check
	}
	// [4] check_sig
	err = this.ptlogin_check_sig(pturl)
	util.Try(err)
	if this.ptwebQQ = this.getCookie(util.MustParseUrl(_PTLOGIN_URL), "ptwebqq"); this.ptwebQQ == "" {
		return fmt.Errorf("[ptwebqq] Failed to read cookie.")
	}
	// [5] login2
	ret, err := this.login2()
	util.Try(err)
	if ret.Code != 0 {
		return fmt.Errorf("[channel_login2] %v : %s", ret.Code, ret.Msg)
	}
	this.vfwebqq = ret.Result.VerifyCode
	this.psessionid = ret.Result.SessionId
	this.Uin = ret.Result.Uin
	util.INFO.Log("[Login] Login success")
	return
}