/// <summary> /// 获取登录uid相关请求参数 /// </summary> /// <returns></returns> /// url->https://login.wx.qq.com/jslogin /// ?appid=wx782c26e4c19acffb /// &redirect_uri=https%3A%2F%2Fwx.qq.com%2Fcgi-bin%2Fmmwebwx-bin%2Fwebwxnewloginpage /// &fun=new /// &lang=zh_CN /// &_=1499308667244 public static HttpTaskParams GetLoginUidParams() { HttpTaskParams htp = HttpTaskParams.NewGet(WxHttpApi.GetLoginUrl(WxHttpApi.URL_LOGIN_UID)); htp.AddStringParam("appid", "wx782c26e4c19acffb"); htp.AddStringParam("fun", "new"); htp.AddStringParam("lang", "zh_CN"); htp.AddStringParam("_", TimeUtil.CurrentTimeMillis().ToString()); htp.AddStringParam("redirect_uri", WxHttpApi.URL_WX_JS_LOGIN_REDIRECT_URI); return(htp); }
/// <summary> /// 获取二维码扫描结果请求 /// </summary> /// <param name="uid"></param> /// <param name="tip"></param> /// <returns></returns> /// url->https://login.wx.qq.com/cgi-bin/mmwebwx-bin/login /// ?loginicon=true /// &uuid=Ifv-J92fbw== /// &tip=0& /// r=-366287686& /// _=1499309823465 public static HttpTaskParams GetLoginScanParams(string uid, string tip) { HttpTaskParams htp = HttpTaskParams.NewGet(WxHttpApi.GetLoginUrl(WxHttpApi.URL_LOGIN_QRCODE_SCAN_CHECK)); htp.AddStringParam("uuid", uid); htp.AddStringParam("tip", tip); htp.AddStringParam("loginicon", "true"); long millis = TimeUtil.CurrentTimeMillis(); htp.AddStringParam("r", ((millis / 1000)).ToString());//时间戳取反 htp.AddStringParam("_", millis.ToString()); return(htp); }
public static HttpTaskParams GetUploadImage(string host, WxAccount account, string toUserNameId, string imagePath) { string url = string.Format("{0}?f=json", WxHttpApi.GetFileUploadUrl(host, WxHttpApi.URL_WX_FILE_UPLOAD)); HttpTaskParams htp = HttpTaskParams.NewPost(url); FileInfo info = new FileInfo(imagePath); htp.AddStringParam("id", "WU_FILE_" + fileCount); htp.AddStringParam("name", info.Name); htp.AddStringParam("type", "image/jpeg"); htp.AddStringParam("lastModifiedDate", info.LastWriteTime.ToString("r", DateTimeFormatInfo.InvariantInfo)); htp.AddStringParam("size", info.Length.ToString()); htp.AddStringParam("mediatype", "pic"); htp.AddStringParam("webwx_data_ticket", account.DataTicket); htp.AddStringParam("pass_ticket", account.PassTicket); htp.AddFileParam("filename", imagePath, WxReqUtil.GetImageMimeType(info)); htp.AddStringParam("uploadmediarequest", WxReqUtil.GetUploadMediaRequestBody(account, toUserNameId, info, imagePath)); return(htp); }
/// <summary> /// 获取同步检查参数 /// </summary> /// <param name="account"></param> /// <param name="deviceId"></param> /// <param name="wxSyncKey"></param> /// <returns></returns> /// https://webpush.wx2.qq.com/cgi-bin/mmwebwx-bin/synccheck /// ?r=1501480039641 /// &skey=%40crypt_77e833b9_e705acd2a3250d78bdbb1137d87afad5&sid=TlG7spFxhWig3TpY /// &uin=243082945 /// &deviceid=e835949820036438 /// &synckey=1_653730215%7C2_653730255%7C3_653730169%7C1000_1501462441 /// &_=1501479916949 public static HttpTaskParams GetSyncCheckParams(string host, WxAccount wxAccount, WxSyncKey wxSyncKey) { HttpTaskParams htp = HttpTaskParams.NewGet(WxHttpApi.GetWebPushUrl(host, WxHttpApi.URL_WX_MSG_CHECK)); htp.AddStringParam("skey", wxAccount.Skey); htp.AddStringParam("uin", wxAccount.Uin); htp.AddStringParam("sid", wxAccount.Sid); htp.AddStringParam("deviceid", wxAccount.DeviceId); htp.AddStringParam("synckey", WxReqUtil.GetSyncKey2String(wxSyncKey)); long millis = TimeUtil.CurrentTimeMillis(); htp.AddStringParam("r", millis.ToString()); htp.AddStringParam("_", (millis / 1000).ToString());//时间戳取反 return(htp); }
/// <summary> /// 上传视频文件 /// </summary> /// <param name="host"></param> /// <param name="account"></param> /// <param name="toUserNameId"></param> /// <param name="videoPath"></param> /// <returns></returns> /// https://file.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json public static HttpTaskParams GetUploadVideo(string host, WxAccount account, string toUserNameId, string videoPath) { string url = string.Format("{0}?f=json", WxHttpApi.GetFileUploadUrl(host, WxHttpApi.URL_WX_FILE_UPLOAD)); HttpTaskParams htp = HttpTaskParams.NewPost(url); FileInfo info = new FileInfo(videoPath); htp.AddStringParam("id", "WU_FILE_" + fileCount); htp.AddStringParam("name", info.Name); htp.AddStringParam("type", WxReqUtil.GetVideoMimeType(info));//"video/mp4" htp.AddStringParam("lastModifiedDate", info.LastWriteTime.ToString("r", DateTimeFormatInfo.InvariantInfo)); htp.AddStringParam("size", info.Length.ToString()); htp.AddStringParam("chunks", "1"); //分段数,这里一次上传,不分段 htp.AddStringParam("chunk", "0"); //第几段 htp.AddStringParam("mediatype", "video"); htp.AddStringParam("uploadmediarequest", WxReqUtil.GetUploadMediaRequestBody(account, toUserNameId, info, videoPath)); htp.AddStringParam("webwx_data_ticket", account.DataTicket); htp.AddStringParam("pass_ticket", account.PassTicket); htp.AddFileParam("filename", videoPath); return(htp); }