Example #1
0
func (this *TargetSinaWeibo) Send(src *source.FeedInfo) (rid string, e error) {
	util.DEBUG.Logf("SinaWeibo.Send(%v:%v,repost_id:%v,title:%v,content:%v,picurl:%v)", src.SourceId, src.Id, src.RepostId, src.Title, src.Content, src.PicUrl)
	if src.RepostId != "" {
		r, err := this.Repost(src.Content, src.RepostId)
		if err != nil {
			e = err
			return
		}
		util.INFO.Log("[sina."+this.Name+"] Repost sent:", r.Url())
		return util.ToString(r.Id), nil
	} else if src.PicUrl != nil && len(src.PicUrl) > 0 {
		if this.EnableUploadUrl {
			r, err := this.UploadUrl(src.Content, src.PicUrl[0])
			if err != nil {
				e = err
				return
			}
			util.INFO.Log("[sina.%s] UploadUrl sent: %v", this.Name, r.Url())
			return util.ToString(r.Id), nil
		} else {
			pic := util.FetchImageAsStream(src.PicUrl[0])
			r, err := this.Upload(src.Content, pic)
			if err != nil {
				e = err
				return
			}
			util.INFO.Log("[sina.%s] Upload sent: %v", this.Name, r.Url())
			return util.ToString(r.Id), nil
		}
	} else {
		r, err := this.Update(src.Content)
		if err != nil {
			e = err
			return
		}
		util.INFO.Log("Update sent:", r.Url())
		return util.ToString(r.Id), nil
	}
	return
}
Example #2
0
func (this *Tieba) Login() (err error) {
	result, err2 := this.login("", "")
	err = err2
reset:
	if result.ErrorCode == 5 && result.Anti.NeedVcode == 1 {
		util.INFO.Log("[首次登录尝试失败]", result.ErrorMsg)
		vcode := ""
	retype:
		img, _, _ := image.Decode(util.FetchImageAsStream(result.Anti.VcodePicUrl))
		vcode = this.VcodeHandler(img)
		if vcode == "" {
			goto retype
		}
		result, err = this.login(vcode, result.Anti.VcodeMd5)
	}
	if result.ErrorCode != 0 {
		if result.ErrorCode != 5 {
			util.INFO.Log(result.ErrorMsg)
		}
		goto reset
	}
	this.BDUSS = result.User.BDUSS
	return
}