Example #1
0
 private void SynckeyTimer_Elapsed(object sender, ElapsedEventArgs e)
 {
     if (!Logined)//展示二维码
     {
         if (ShowImg)
         {
             return;
         }
         DisplayQRCodeFunc(getWx_Code());
     }
     else
     {
         if (!Inited)
         {
             return;
         }
         synCheckGet(MsgNoticeFunc);
         NewestMsgClass ret = getCurrentMsgData(MsgNoticeFunc);
         if (ret != null)
         {
             ReceivedMsg(ret);
         }
     }
 }
Example #2
0
        public NewestMsgClass getCurrentMsgData(Action <string, string, string> NoticeFunc)
        {
            if (!HasNewMsg)
            {
                return(null);
            }
            string        url = string.Format(NewestMsgUrlModel, strHostFlg, this.wxsid, this.skey, this.wxuin);
            NewMsgRequest nmr = new NewMsgRequest();

            nmr.BaseRequest = this.baseReqObj.BaseRequest;
            nmr.SyncKey     = this.syncObj;// new SyncKeys().LoadFromJson<SyncKeys>(this.syncCheckKey);
            nmr.rr          = -1 * this.GetTimeStamp();
            try
            {
                wc.Headers.Add("Content-Type", "application/json; charset=UTF-8");
                wc.Headers.Add("Cookie", this.Cookie);
                byte[]         byteRet = wc.UploadData(url, Encoding.UTF8.GetBytes(nmr.ToJson()));
                string         strRet  = Encoding.UTF8.GetString(byteRet);
                NewestMsgClass retobj  = new NewestMsgClass().LoadFromJson <NewestMsgClass>(strRet);
                string         msg     = null;
                if (retobj.SyncCheckKey != null)
                {
                    //this.syncCheckKey = retobj.SyncCheckKey.ToJson();
                    this.syncObj            = retobj.SyncCheckKey;
                    this.NewestSyncCheckKey = syncObj.ToString();
                }
                return(retobj);
            }
            catch (Exception ce)
            {
                NoticeFunc("获取最新消息", ce.Message, ce.StackTrace);
                return(null);
            }
            //////            Function getCurrentMsgData() As WXMsg()
            //////    Dim postUrl As String
            //////    Dim ret() As WXMsg
            //////    strHostFlg = Sheet10.cells(5, 1)
            //////    postUrl = "https://wx" & strHostFlg & ".qq.com/cgi-bin/mmwebwx-bin/webwxsync?sid=" & wxsid & "&skey=" & skey
            //////    Dim strModel As String
            //////    Dim strPost As String
            //////    strStamp = getTimeStap()
            //////    skey = Sheet10.cells(2, 12).Text
            //////    wxsid = Sheet10.cells(2, 13).Text
            //////    wxuin = Sheet10.cells(2, 14).Text
            //////    pass_ticket = Sheet10.cells(2, 15).Text
            //////    SyncKey = Sheet10.cells(1, 8)
            //////    syncCheckKey = Sheet10.cells(2, 8)
            //////    cookie = Sheet10.cells(1, 1).Text
            //////    strModel = "{""BaseRequest"":{""Uin"":""UUUU"",""Sid"":""SSSS"",""Skey"":""KKKK"",""DeviceID"":""eDDDD""},""SyncKey"":{NNNN},""rr"":RRRR}"
            //////    strPost = Replace(strModel, "UUUU", wxuin)
            //////    strPost = Replace(strPost, "SSSS", wxsid)
            //////    strPost = Replace(strPost, "KKKK", skey)
            //////    strPost = Replace(strPost, "DDDD", Right("00000000000" & strStamp, 15))
            //////    strPost = Replace(strPost, "NNNN", SyncKey)
            //////    strPost = Replace(strPost, "RRRR", strStamp)
            //////    Sheet10.cells(8, 11) = strPost
            //////    'paramData = strPost
            //////    Dim jc As New JsonClass
            //////    Set obj = jc.GetJsonVal(strPost, "")
            //////    If obj Is Nothing Then
            //////        MsgBox "构建请求错误!" & strPost
            //////       ' Exit Function
            //////    End If
            //////    Dim httpreq As New XMLHTTP60
            //////    httpreq.Open "post", postUrl, False
            //////    httpreq.setRequestHeader "contentType", "application/json; charset=UTF-8"
            //////    httpreq.setRequestHeader "Cookie", cookie
            //////    httpreq.send strPost
            //////    If httpreq.Status <> 200 Then
            //////        ReDim ret(0)
            //////        getCurrentMsgData = ret
            //////        Exit Function
            //////    End If
            //////    Dim Msg As New WXMsg

            //////    Set obj = jc.GetJsonVal(httpreq.responseText, "")
            //////    If obj.BaseResponse.ret <> 0 Then
            //////        MsgBox obj.retcode
            //////        Exit Function
            //////    End If
            //////    getCurrentMsgData = Msg.LoadMsgsByText(httpreq.responseText)
            //////End Function
        }