void 步消息() { //string url = "http://webpush.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck" + // "?pass_ticket=" + Data.pass_ticket + // "&skey=" + Data.skey + // "&sid=" + Data.wxsid + // "&uin=" + Data.wxuin + // "&deviceid=" + Data.device_id + // "&synckey=" + Data.synckey.get_urlstring() + // "&_=" + Time.Now(); ///cgi-bin/mmwebwx-bin/synccheck?r=1440585331636&skey=%40crypt_67c13b2d_631cde5822b6fd866704b9045a13d17c&sid=jmTznox8qavfBu7%2F&uin=1547229180&deviceid=e824539813213050&synckey=1_637639781%7C2_637649490%7C3_637649454%7C11_637649450%7C201_1440585302%7C1000_1440581558 string url = string.Format("https://webpush2.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck?r={0}&pass_ticket={1}&sid={2}&skey={3}&uin={4}&deviceid={5}&synckey={6}&lang=zh_CN", Time.Now(), Data.pass_ticket, Data.wxsid, Data.skey, Data.wxuin, Data.device_id, Data.synckey.get_urlstring()); WebRequest request = WebRequest.Create(url); WebResponse response = request.GetResponse(); Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string ret_str = reader.ReadToEnd().Split('=')[1]; synccheck ret = JsonConvert.DeserializeObject <synccheck>(ret_str); reader.Close(); dataStream.Close(); response.Close(); Trace.WriteLine("同步消息"); //Trace.WriteLine(url); Trace.WriteLine(ret_str); if (!ret.retcode.Equals("0")) { //MessageBox.Show("同步失败,synccheck.retcode:" + ret.retcode, "错误", MessageBoxButton.OK, MessageBoxImage.Information); //Close(); Trace.WriteLine("同步失败,synccheck.retcode:" + ret.retcode); } if (!ret.selector.Equals("0")) { 读取消息(); } }
void 步消息() { string url = "http://webpush.weixin.qq.com/cgi-bin/mmwebwx-bin/synccheck" + "?pass_ticket=" + Data.pass_ticket + "&skey=" + Data.skey + "&sid=" + Data.wxsid + "&uin=" + Data.wxuin + "&deviceid=" + Data.device_id + "&synckey=" + Data.synckey.get_urlstring() + "&_=" + Time.Now(); WebRequest request = WebRequest.Create(url); WebResponse response = request.GetResponse(); Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string ret_str = reader.ReadToEnd().Split('=')[1]; synccheck ret = JsonConvert.DeserializeObject <synccheck>(ret_str); reader.Close(); dataStream.Close(); response.Close(); Trace.WriteLine("同步消息"); //Trace.WriteLine(url); Trace.WriteLine(ret_str); if (!ret.retcode.Equals("0")) { MessageBox.Show("同步失败,synccheck.retcode:" + ret.retcode, "错误", MessageBoxButton.OK, MessageBoxImage.Information); Close(); } if (!ret.selector.Equals("0")) { 读取消息(); } }